NoHtmlTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dataOWASP() 0 12 3
A testOWASP() 0 12 1
1
<?php
2
3
namespace PhpNoHtmlTest;
4
5
class NoHtmlTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @source https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
9
     * @return array[]
10
     */
11
    public function dataOWASP()
12
    {
13
        $exploits = [];
14
        
15
        foreach (new \DirectoryIterator(__DIR__ . '/exploits') as $file) {
16
            if ($file->isFile()) {
17
                $exploits[$file->getBasename()] = [file_get_contents($file->getRealPath())];
18
            }
19
        }
20
        
21
        return $exploits;
22
    }
23
24
    /**
25
     * @dataProvider dataOWASP
26
     * @param mixed $value
27
     */
28
    public function testOWASP($value)
29
    {
30
        self::assertNotEmpty($value);
31
        
32
        $actual = \NoHtml\noHtml($value);
33
        
34
        self::assertNotEmpty($actual);
35
        self::assertNotContains('<', $actual);
36
        self::assertNotContains('>', $actual);
37
        self::assertNotContains('"', $actual);
38
        self::assertNotContains("'", $actual);
39
    }
40
}
41