first commit

This commit is contained in:
2020-05-20 15:48:29 +02:00
commit cf7a95d818
66 changed files with 3552 additions and 0 deletions
@@ -0,0 +1,22 @@
<?php
$_tests_dir = getenv('WP_TESTS_DIR');
if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() {
$plugins_dir = dirname( __FILE__ ).'/../../../plugins';
$timber = $plugins_dir.'/timber/timber.php';
if ( file_exists($timber) ) {
require_once($timber);
} else {
$timber_library = $plugins_dir.'/timber-library/timber.php';
if ( file_exists($timber_library) ) {
require_once($timber_library);
}
}
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
require $_tests_dir . '/includes/bootstrap.php';
@@ -0,0 +1,55 @@
<?php
class TestTimberStarterTheme extends WP_UnitTestCase {
function setUp() {
self::_setupStarterTheme();
switch_theme( basename( dirname( dirname( __FILE__ ) ) ) );
require_once(__DIR__.'/../functions.php');
}
function tearDown() {
switch_theme('twentythirteen');
}
function testTimberExists() {
$context = Timber::context();
$this->assertTrue(is_array($context));
}
function testFunctionsPHP() {
$context = Timber::context();
$this->assertEquals('StarterSite', get_class($context['site']));
$this->assertTrue(current_theme_supports('post-thumbnails'));
$this->assertEquals('bar', $context['foo']);
}
function testLoading() {
$str = Timber::compile('tease.twig');
$this->assertStringStartsWith('<article class="tease tease-" id="tease-">', $str);
$this->assertStringEndsWith('</article>', $str);
}
/**
* Helper test to output current twig version
*/
function testTwigVersion() {
$str = Timber::compile_string("{{ constant('Twig_Environment::VERSION') }}");
//error_log('Twig version = '.$str);
}
function testTwigFilter() {
$str = Timber::compile_string('{{ "foo" | myfoo }}');
$this->assertEquals('foo bar!', $str);
}
static function _setupStarterTheme(){
$dest = WP_CONTENT_DIR . '/themes/' . basename( dirname( dirname( __FILE__ ) ) );
$src = realpath( __DIR__ . '/../../' . basename( dirname( dirname( __FILE__ ) ) ) );
if ( is_dir($src) && !file_exists($dest) ) {
symlink($src, $dest);
}
}
}