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

SanitizerHelperTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSanitizerHelperCanBeInstantiated() 0 7 1
A testSanitizerRemovesScriptTagsFromAHtmlString() 0 10 1
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
}