ReplaceTest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
namespace HtmlTagReplace\Test;
4
5
use HtmlTagReplace\HtmlTagReplace;
6
7
/**
8
 * Class ReplaceTest
9
 * @package HtmlTagReplace\Test
10
 */
11
class ReplaceTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var HtmlTagReplace
15
     */
16
    private $replacer;
17
18
    public function __construct($name = NULL, array $data = array(), $dataName = '')
19
    {
20
        parent::__construct($name, $data, $dataName);
21
22
        $this->replacer = new HtmlTagReplace(<<<EOF
23
<img src="#" alt="nope">
24
<img src="#">
25
<div id="foo">bar</div>
26
<em class="foo">bar</em>
27
<input type="text" name="foo">
28
EOF
29
        );
30
    }
31
32
    public function testMarkupManipulation()
33
    {
34
        $expected = <<<EOF
35
<a title="show image" href="#">show image</a> <a title="show image" href="#">show image</a> <hr><article class="foo">bar</article> <strong class="foo">bar</strong> <input type="text" name="foo" id="foo">
36
EOF;
37
38
39
        $actual = $this->replacer->replaceTag(
40
            'img',
41
            'a',
42
            false,
43
            ['src' => 'href', 'alt' => false],
44
            'title="show image"',
45
            'show image</a>'
46
        )->replaceTag(
47
            'div',
48
            'article',
49
            true,
50
            ['id' => 'class'],
51
            null,
52
            null,
53
            '<hr>'
54
        )->replaceTag(
55
            'em',
56
            'strong',
57
            true
58
        )->replaceTag(
59
            'input',
60
            'input',
61
            false,
62
            ['name' => ['name', 'id']]
63
        )->compress()->getMarkup();
64
65
66
        $this->assertEquals($expected, $actual);
67
    }
68
}