EscapingTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 49
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B dataProvider() 0 31 1
A testEscaping() 0 4 1
1
<?php
2
3
namespace FlorianKoerner\ChimpDrill\Tests;
4
5
use FlorianKoerner\ChimpDrill\ChimpDrill;
6
7
class EscapingTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @return array
11
     */
12
    public function dataProvider()
13
    {
14
        return array(
15
            array(
16
                'message' => 'Damn! Very cool PHP-Code: <?php echo "evil"; ?>',
17
                'placeholder' => array(),
18
                'expected' => 'Damn! Very cool PHP-Code: <?php echo "evil"; ?>'
19
            ),
20
            array(
21
                'message' => 'And take a look at these HTML-Tags: <strong>Unbelievable!</strong>',
22
                'placeholder' => array(),
23
                'expected' => 'And take a look at these HTML-Tags: <strong>Unbelievable!</strong>'
24
            ),
25
            array(
26
                'message' => 'Your input was *|INPUT|*. Thank you, *|NAME|*.',
27
                'placeholder' => array(
28
                    'NAME' => 'John <hacks>',
29
                    'INPUT' => '<?php var_dump($_SERVER); ?> <strong>I\'m a very bad boy</strong>'
30
                ),
31
                'expected' => 'Your input was &lt;?php var_dump($_SERVER); ?&gt; &lt;strong&gt;I\'m a very bad boy&lt;/strong&gt;. Thank you, John &lt;hacks&gt;.'
32
            ),
33
            array(
34
                'message' => 'Your input was *|HTML:INPUT|*. Thank you, *|HTML:NAME|*.',
35
                'placeholder' => array(
36
                    'NAME' => 'John <hacks>',
37
                    'INPUT' => '<?php var_dump($_SERVER); ?> <strong>I\'m a very bad boy</strong>'
38
                ),
39
                'expected' => 'Your input was <?php var_dump($_SERVER); ?> <strong>I\'m a very bad boy</strong>. Thank you, John <hacks>.'
40
            )
41
        );
42
    }
43
44
    /**
45
     * @param string $message
46
     * @param array  $placeholder
47
     * @param string $expected
48
     *
49
     * @dataProvider dataProvider
50
     */
51
    public function testEscaping($message, array $placeholder, $expected)
52
    {
53
        $this->assertEquals($expected, (string) new ChimpDrill($message, $placeholder));
54
    }
55
}