JsonToHtmlTest::testConvertImageToHtml()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 19
loc 19
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Sioen\Tests;
4
5
use Sioen\JsonToHtml;
6
use Sioen\JsonToHtml\BlockquoteConverter;
7
use Sioen\JsonToHtml\BaseConverter;
8
use Sioen\JsonToHtml\IframeConverter;
9
use Sioen\JsonToHtml\ImageConverter;
10
use Sioen\JsonToHtml\HeadingConverter;
11
12
final class JsonToHtmlTest extends \PHPUnit_Framework_TestCase
13
{
14 View Code Duplication
    public function testConvertBlockquoteToHtml()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
    {
16
        $converter = new JsonToHtml();
17
        $converter->addConverter(new BlockquoteConverter());
18
19
        $json = json_encode(array(
20
            'data' => array(array(
21
                'type' => 'quote',
22
                'data' => array(
23
                    'text' => 'Text',
24
                    'cite' => 'Cite'
25
                )
26
            ))
27
        ));
28
        $html = $converter->toHtml($json);
29
        $this->assertEquals(
30
            $html,
31
            "<blockquote><p>Text</p>\n<cite><p>Cite</p>\n</cite></blockquote>"
32
        );
33
    }
34
35 View Code Duplication
    public function testConvertParagraphToHtml()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $converter = new JsonToHtml();
38
        $converter->addConverter(new BaseConverter());
39
40
        // Lets convert a normal text type that uses the default converter
41
        $json = json_encode(array(
42
            'data' => array(array(
43
                'type' => 'text',
44
                'data' => array(
45
                    'text' => 'test'
46
                )
47
            ))
48
        ));
49
        $html = $converter->toHtml($json);
50
        $this->assertEquals($html, "<p>test</p>\n");
51
    }
52
53 View Code Duplication
    public function testConvertVideoToHtml()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $converter = new JsonToHtml();
56
        $converter->addConverter(new IframeConverter());
57
58
        // the video conversion
59
        $json = json_encode(array(
60
            'data' => array(array(
61
                'type' => 'video',
62
                'data' => array(
63
                    'source' => 'youtube',
64
                    'remote_id' => '4BXpi7056RM'
65
                )
66
            ))
67
        ));
68
        $html = $converter->toHtml($json);
69
        $this->assertEquals(
70
            $html,
71
            "<iframe src=\"//www.youtube.com/embed/4BXpi7056RM?rel=0\" frameborder=\"0\" allowfullscreen></iframe>\n"
72
        );
73
    }
74
75 View Code Duplication
    public function testConvertHeadingToHtml()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $converter = new JsonToHtml();
78
        $converter->addConverter(new HeadingConverter());
79
80
        // The heading
81
        $json = json_encode(array(
82
            'data' => array(array(
83
                'type' => 'heading',
84
                'data' => array(
85
                    'text' => 'test'
86
                )
87
            ))
88
        ));
89
        $html = $converter->toHtml($json);
90
        $this->assertEquals($html, "<h2>test</h2>\n");
91
    }
92
93 View Code Duplication
    public function testConvertImageToHtml()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
    {
95
        $converter = new JsonToHtml();
96
        $converter->addConverter(new ImageConverter());
97
98
        // images
99
        $json = json_encode(array(
100
            'data' => array(array(
101
                'type' => 'image',
102
                'data' => array(
103
                    'file' => array(
104
                        'url' => '/frontend/files/sir-trevor/images/IMG_3867.JPG'
105
                    )
106
                )
107
            ))
108
        ));
109
        $html = $converter->toHtml($json);
110
        $this->assertEquals($html, "<img src=\"/frontend/files/sir-trevor/images/IMG_3867.JPG\" />\n");
111
    }
112
}
113