Completed
Push — master ( dacb23...c4abf4 )
by David
01:54
created

testSanitizerRemovesScriptTagsFromAHtmlString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Test\Unit\Helpers;
4
5
use Test\Unit\TestCase;
6
use Taskforcedev\LaravelForum\Helpers\Sanitizer as SanitizerHelper;
7
8
class SanitizerHelperTest extends TestCase
9
{
10
    public function testSanitizerHelperCanBeInstantiated()
11
    {
12
        $helper = new SanitizerHelper();
13
        $class = get_class($helper);
14
        $this->assertEquals('Taskforcedev\LaravelForum\Helpers\Sanitizer', $class,
15
            'Sanitizer helper should return the correct class.');
16
    }
17
18
    public function testSanitizerRemovesScriptTagsFromAHtmlString()
19
    {
20
        $helper = new SanitizerHelper();
21
        $html = '<!DOCTYPE html><html><head></head><body><h1>This is my test page</h1><script>alert(\'hello\');</script></body></html>';
22
23
        $output = $helper->sanitize($html);
24
25
        $this->assertRegExp('/script/', $html, 'HTML string given does regexp match script tag.');
26
        $this->assertNotRegExp('/script/', $output, 'Output should not match script tags.');
27
    }
28
}