1
|
|
|
<?php |
2
|
|
|
class PageTest extends \PHPUnit\Framework\TestCase |
3
|
|
|
{ |
4
|
|
|
public function testLanguage() |
5
|
|
|
{ |
6
|
|
|
$page = new \Suricate\Page(); |
7
|
|
|
$page->setLanguage('fr_FR'); |
8
|
|
|
$this->assertAttributeEquals('fr_FR', 'language', $page); |
|
|
|
|
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
public function testEncoding() |
12
|
|
|
{ |
13
|
|
|
$page = new \Suricate\Page(); |
14
|
|
|
$page->setEncoding('iso-8859-1'); |
15
|
|
|
$this->assertAttributeEquals('iso-8859-1', 'encoding', $page); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testTitle() |
19
|
|
|
{ |
20
|
|
|
$page = new \Suricate\Page(); |
21
|
|
|
$page->setTitle('My great webpage'); |
22
|
|
|
$this->assertAttributeEquals('My great webpage', 'title', $page); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testAddStylesheet() |
26
|
|
|
{ |
27
|
|
|
$page = new \Suricate\Page(); |
28
|
|
|
$page->addStylesheet('stylesheet-ref', '/my.css'); |
29
|
|
|
|
30
|
|
|
$reflector = new ReflectionClass(get_class($page)); |
31
|
|
|
$property = $reflector->getProperty('stylesheets'); |
32
|
|
|
$property->setAccessible(true); |
33
|
|
|
|
34
|
|
|
$this->assertEquals( |
35
|
|
|
$property->getValue($page), |
36
|
|
|
[ |
37
|
|
|
'stylesheet-ref' => ['url' => '/my.css', 'media' => 'all'], |
38
|
|
|
] |
39
|
|
|
); |
40
|
|
|
$this->assertNotEquals( |
41
|
|
|
$property->getValue($page), |
42
|
|
|
[ |
43
|
|
|
'another-stylesheet' => ['url' => '/my-2.css', 'media' => 'all'], |
44
|
|
|
] |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testRender() |
49
|
|
|
{ |
50
|
|
|
$page = new \Suricate\Page(); |
51
|
|
|
$this->assertEquals('<!DOCTYPE html> |
52
|
|
|
<html lang="en"> |
53
|
|
|
<head> |
54
|
|
|
<title></title> |
55
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
56
|
|
|
</head> |
57
|
|
|
<body> |
58
|
|
|
</body> |
59
|
|
|
</html>', $page->render()); |
60
|
|
|
|
61
|
|
|
$page->setTitle('My Pageé'); |
62
|
|
|
$this->assertEquals('<!DOCTYPE html> |
63
|
|
|
<html lang="en"> |
64
|
|
|
<head> |
65
|
|
|
<title>My Pageé</title> |
66
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
67
|
|
|
</head> |
68
|
|
|
<body> |
69
|
|
|
</body> |
70
|
|
|
</html>', $page->render()); |
71
|
|
|
|
72
|
|
|
$page->addHtmlClass('class1'); |
73
|
|
|
$page->addHtmlClass('class2'); |
74
|
|
|
|
75
|
|
|
$this->assertEquals('<!DOCTYPE html> |
76
|
|
|
<html lang="en" class="class1 class2"> |
77
|
|
|
<head> |
78
|
|
|
<title>My Pageé</title> |
79
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
80
|
|
|
</head> |
81
|
|
|
<body> |
82
|
|
|
</body> |
83
|
|
|
</html>', $page->render()); |
84
|
|
|
|
85
|
|
|
$page->addScript('script-id', 'http://scripturl.com'); |
86
|
|
|
$page->addRss('rss-id', 'http://rssurl.com', 'RSS is not dead !'); |
87
|
|
|
$page->addStylesheet('css-id', 'http://cssurl.com'); |
88
|
|
|
$page->addMeta('metaname', 'metacontent'); |
89
|
|
|
$page->addMetaProperty('metapropertyname', 'metapropertycontent'); |
90
|
|
|
$page->addMetaLink('metalinkname', 'metalinktype', 'metalinkhref'); |
91
|
|
|
|
92
|
|
|
$this->assertEquals('<!DOCTYPE html> |
93
|
|
|
<html lang="en" class="class1 class2"> |
94
|
|
|
<head> |
95
|
|
|
<title>My Pageé</title> |
96
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
97
|
|
|
<meta name="metaname" content="metacontent"/> |
98
|
|
|
<meta property="metapropertyname" content="metapropertycontent"/> |
99
|
|
|
<link rel="metalinktype" href="metalinkhref"/> |
100
|
|
|
<link rel="stylesheet" id="css-id" href="http://cssurl.com" type="text/css" media="all"/> |
101
|
|
|
<script type="text/javascript" src="http://scripturl.com"></script> |
102
|
|
|
<link rel="alternate" id="rss-id" href="http://rssurl.com" type="application/rss+xml" media="RSS is not dead !"/> |
103
|
|
|
</head> |
104
|
|
|
<body> |
105
|
|
|
</body> |
106
|
|
|
</html>', $page->render()); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.