-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
test-timber-starter-theme.php
57 lines (44 loc) · 1.47 KB
/
test-timber-starter-theme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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);
}
}