forked from catchpoint/WebPageTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateTest.php
54 lines (50 loc) · 1.58 KB
/
TemplateTest.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
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use WebPageTest\Template;
final class TemplateTest extends TestCase
{
public function testConstructorSetsDefaults(): void
{
$dir = realpath(WWW_PATH . '/templates');
$layout = realpath(WWW_PATH . '/templates/layouts/default.php');
$tpl = new Template();
$this->assertEquals($dir, $tpl->getDir());
$this->assertEquals($layout, $tpl->getLayout());
}
public function testConstructorSetsValues(): void
{
$dir = realpath(WWW_PATH . '/templates/errors');
$layout = realpath(WWW_PATH . '/templates/layouts/default.php');
$tpl = new Template('errors');
$this->assertEquals($dir, $tpl->getDir());
$this->assertEquals($layout, $tpl->getLayout());
}
public function testSetLayout(): void
{
$tpl = new Template();
$tpl->setLayout('../../../tests/fixtures/layout-1');
$layout = realpath(TESTS_PATH . '/fixtures/layout-1.php');
$this->assertEquals($tpl->getLayout(), $layout);
}
public function testRenderReturnsRenderedString(): void
{
$dir = realpath(TESTS_PATH . '/fixtures');
$tpl = new Template('../../tests/fixtures');
$tpl->setLayout('../../../tests/fixtures/layout-1');
$this->assertEquals($dir, $tpl->getDir());
$val = $tpl->render('template-1', array(
'name' => 'Jeff'
));
$expected = "<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>Hi Jeff</div>
</body>
</html>
";
$this->assertEquals($expected, $val);
}
}