Completed
Push — master ( 4bb011...4b99be )
by Guillaume
13:23
created

RenderManagerTest::testRenderWithoutVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Starkerxp\CampaignBundle\Tests\Render;
4
5
6
use Starkerxp\CampaignBundle\Render\RenderManager;
7
8
class RenderManagerTest extends \Starkerxp\StructureBundle\Tests\WebTest
9
{
10
11
    /** @var  RenderManager */
12
    protected $renderService;
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
        $this->renderService = $this->getContainer()->get('starkerxp_campaign.manager.render');
18
19
20
    }
21
22
    public function dataProvider()
23
    {
24
        $export = [
25
            'lien mirroir'        => [
26
                '[{@mirror}]',
27
                [],
28
                '',
29
            ],
30
            'pixel'               => [
31
                '[{@pixel}]',
32
                [],
33
                '',
34
            ],
35
            'lien desinscription' => [
36
                '<a data-id="unsub" target="__blank" href="http://google.fr" style="color:black;">Mon lien</a>',
37
                [],
38
                "Mon lien (http://google.fr)",
39
            ],
40
            'lien clickable'      => [
41
                '<a data-id="click" target="__blank" href="http://google.fr" style="color:black;">Mon lien</a>',
42
                [],
43
                "Mon lien (http://google.fr)",
44
            ],
45
        ];
46
47
        return $export;
48
    }
49
50
    /**
51
     * @group campaign
52
     * @group render
53
     * @group renderManager
54
     *
55
     * @dataProvider dataProvider
56
     */
57
    public function testRender($message, $params, $expected)
58
    {
59
        $this->renderService->setApi("");
60
        $this->renderService->setVersion("txt");
61
        $this->renderService->setContenu($message);
62
        $this->renderService->setData($params);
63
        $actual = $this->renderService->render();
64
        $this->assertEquals($expected, $actual);
65
    }
66
67
    /**
68
     * @group campaign
69
     * @group render
70
     * @group renderManager
71
     *
72
     * @expectedException \Starkerxp\CampaignBundle\Render\Exception\ApiNotDefinedException
73
     */
74
    public function testRenderWithoutApi()
75
    {
76
        $this->renderService->setVersion("txt");
77
        $this->renderService->setContenu("Mon message");
78
        $this->renderService->setData([]);
79
        $this->renderService->render();
80
    }
81
82
    /**
83
     * @group campaign
84
     * @group render
85
     * @group renderManager
86
     *
87
     * @expectedException \Starkerxp\CampaignBundle\Render\Exception\VersionNotDefinedException
88
     */
89
    public function testRenderWithoutVersion()
90
    {
91
        $this->renderService->setApi("twig");
92
        $this->renderService->setContenu("Mon message");
93
        $this->renderService->setData([]);
94
        $this->renderService->render();
95
    }
96
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
97