first commit

This commit is contained in:
2025-07-14 07:33:32 +00:00
commit 64f6de30fb
41 changed files with 958 additions and 0 deletions

28
tests/bootstrap.php Normal file
View File

@ -0,0 +1,28 @@
<?php
use WorDBless\Load;
if (! file_exists(dirname(__DIR__) . '/wordpress/wp-content')) {
mkdir(dirname(__DIR__) . '/wordpress/wp-content');
}
if (! file_exists(dirname(__DIR__) . '/wordpress/wp-content/themes')) {
mkdir(dirname(__DIR__) . '/wordpress/wp-content/themes');
}
copy(
dirname(__DIR__) . '/vendor/automattic/wordbless/src/dbless-wpdb.php',
dirname(__DIR__) . '/wordpress/wp-content/db.php'
);
$theme_base_name = basename(dirname(__DIR__));
$src = realpath(dirname(dirname(__DIR__)) . '/' . $theme_base_name);
$dest = dirname(__DIR__) . '/wordpress/wp-content/themes/' . $theme_base_name;
if ( is_dir($src) && ! file_exists($dest) ) {
symlink($src, $dest);
}
require_once dirname(__DIR__) . '/vendor/autoload.php';
Load::load();

View File

@ -0,0 +1,64 @@
<?php
use Timber\Timber;
use WorDBless\BaseTestCase;
class TestTimberStarterTheme extends BaseTestCase
{
public function set_up()
{
switch_theme(basename(dirname(__DIR__)) . '/theme');
require dirname(__DIR__) . '/functions.php';
Timber::$dirname = array_merge((array) Timber::$dirname, ['../views']);
Timber::$dirname = array_unique(Timber::$dirname);
// WorDBless includes wp-settings.php
do_action('after_setup_theme');
parent::set_up();
}
function tear_down()
{
parent::tear_down();
switch_theme('twentytwenty');
}
function testTimberExists()
{
$context = Timber::context();
$this->assertTrue(is_array($context));
}
function testFunctionsPHP()
{
$context = Timber::context();
$this->assertEquals('App\StarterSite', get_class($context['site']));
$this->assertTrue(current_theme_supports('post-thumbnails'));
$this->assertEquals('bar', $context['foo']);
}
function testLoading()
{
$str = Timber::compile('partials/tease.twig');
$this->assertStringStartsWith('<article class="tease tease-" id="tease-">', $str);
$this->assertStringEndsWith('</article>', $str);
}
/**
* Helper test to output current twig version
*/
function testTwigVersion()
{
$version = Timber::compile_string("{{ version }}", ['version' => Twig\Environment::VERSION]);
$this->assertEquals(Twig\Environment::VERSION, $version);
}
// function testTwigFilter() {
// $str = Timber::compile_string('{{ "foo"|myfoo }}');
// $this->assertEquals('foo bar!', $str);
// }
}