forked from paquettg/php-html-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrictTest.php
More file actions
55 lines (50 loc) · 1.54 KB
/
Copy pathStrictTest.php
File metadata and controls
55 lines (50 loc) · 1.54 KB
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
<?php
use PHPHtmlParser\Dom;
use PHPHtmlParser\Exceptions\StrictException;
class StrictTest extends PHPUnit_Framework_TestCase {
public function testConfigStrict()
{
$dom = new Dom;
$dom->setOptions([
'strict' => true,
]);
$dom->load('<div><p id="hey">Hey you</p> <p id="ya">Ya you!</p></div>');
$this->assertEquals(' ', $dom->getElementById('hey')->nextSibling()->text);
}
public function testConfigStrictMissingSelfClosing()
{
$dom = new Dom;
$dom->setOptions([
'strict' => true,
]);
try
{
// should throw an exception
$dom->load('<div><p id="hey">Hey you</p><br><p id="ya">Ya you!</p></div>');
// we should not get here
$this->assertTrue(false);
}
catch (StrictException $e)
{
$this->assertEquals("Tag 'br' is not self closing! (character #31)", $e->getMessage());
}
}
public function testConfigStrictMissingAttribute()
{
$dom = new Dom;
$dom->setOptions([
'strict' => true,
]);
try
{
// should throw an exception
$dom->load('<div><p id="hey" block>Hey you</p> <p id="ya">Ya you!</p></div>');
// we should not get here
$this->assertTrue(false);
}
catch (StrictException $e)
{
$this->assertEquals("Tag 'p' has an attribute 'block' with out a value! (character #22)", $e->getMessage());
}
}
}