/var/www/hkosl.com/b2b2c/webadmin/libraies/paquettg/php-html-parser/tests/Options/CleanupTest.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

use PHPHtmlParser\Dom;

class 
CleanupTest extends PHPUnit_Framework_TestCase {

    public function 
testCleanupInputTrue()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'cleanupInput' => true,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(0count($dom->find('style')));
        
$this->assertEquals(0count($dom->find('script')));
    }

    public function 
testCleanupInputFalse()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'cleanupInput' => false,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(1count($dom->find('style')));
        
$this->assertEquals(1count($dom->find('script')));
    }

    public function 
testRemoveStylesTrue()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'removeStyles' => true,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(0count($dom->find('style')));
    }

    public function 
testRemoveStylesFalse()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'removeStyles' => false,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(1count($dom->find('style')));
        
$this->assertEquals('text/css',
            
$dom->find('style')->getAttribute('type'));
    }

    public function 
testRemoveScriptsTrue()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'removeScripts' => true,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(0count($dom->find('script')));
    }

    public function 
testRemoveScriptsFalse()
    {
        
$dom = new Dom;
        
$dom->setOptions([
            
'removeScripts' => false,
        ]);
        
$dom->loadFromFile('tests/files/horrible.html');
        
$this->assertEquals(1count($dom->find('script')));
        
$this->assertEquals('text/JavaScript',
            
$dom->find('script')->getAttribute('type'));
    }

}