Completed
Branch master (0b86d9)
by Léo
02:17
created

TwitterSeoConfiguratorTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Tests\Seo\Twitter;
4
5
use Leogout\Bundle\SeoBundle\Builder\TagBuilder;
6
use Leogout\Bundle\SeoBundle\Factory\TagFactory;
7
use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator;
8
use Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoConfigurator;
9
use Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoGenerator;
10
use Leogout\Bundle\SeoBundle\Tests\TestCase;
11
12
/**
13
 * Description of TwitterSeoConfiguratorTest.
14
 *
15
 * @author: leogout
16
 */
17
class TwitterSeoConfiguratorTest extends TestCase
18
{
19
    /**
20
     * @var TwitterSeoGenerator
21
     */
22
    protected $generator;
23
24
    protected function setUp()
25
    {
26
        $this->generator = new TwitterSeoGenerator(new TagBuilder(new TagFactory()));
27
    }
28
29
    /**
30
     * @expectedException \Leogout\Bundle\SeoBundle\Exception\InvalidSeoGeneratorException
31
     * @expectedExceptionMessage Invalid seo generator passed to Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoConfigurator. Expected "Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoGenerator", but got "Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator".
32
     */
33
    public function testException()
34
    {
35
        $invalidGenerator = new OgSeoGenerator(new TagBuilder(new TagFactory()));
36
        $configurator = new TwitterSeoConfigurator([]);
37
        $configurator->configure($invalidGenerator);
38
    }
39
40 View Code Duplication
    public function testTitle()
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...
41
    {
42
        $config = [
43
            'title' => 'Awesome | Site'
44
        ];
45
46
        $configurator = new TwitterSeoConfigurator($config);
47
        $configurator->configure($this->generator);
48
49
        $this->assertEquals(
50
            '<meta name="twitter:title" content="Awesome | Site" />',
51
            $this->generator->render()
52
        );
53
    }
54
55 View Code Duplication
    public function testDescription()
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...
56
    {
57
        $config = [
58
            'description' => 'My awesome site is so cool!',
59
        ];
60
61
        $configurator = new TwitterSeoConfigurator($config);
62
        $configurator->configure($this->generator);
63
64
        $this->assertEquals(
65
            '<meta name="twitter:description" content="My awesome site is so cool!" />',
66
            $this->generator->render()
67
        );
68
    }
69
70 View Code Duplication
    public function testImage()
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...
71
    {
72
        $config = [
73
            'image' => 'http://images.com/poney/12',
74
        ];
75
76
        $configurator = new TwitterSeoConfigurator($config);
77
        $configurator->configure($this->generator);
78
79
        $this->assertEquals(
80
            '<meta name="twitter:image" content="http://images.com/poney/12" />',
81
            $this->generator->render()
82
        );
83
    }
84
85 View Code Duplication
    public function testCard()
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...
86
    {
87
        $config = [
88
            'card' => 'summary',
89
        ];
90
91
        $configurator = new TwitterSeoConfigurator($config);
92
        $configurator->configure($this->generator);
93
94
        $this->assertEquals(
95
            '<meta name="twitter:card" content="summary" />',
96
            $this->generator->render()
97
        );
98
    }
99
100 View Code Duplication
    public function testSite()
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...
101
    {
102
        $config = [
103
            'site' => '@leogoutt',
104
        ];
105
106
        $configurator = new TwitterSeoConfigurator($config);
107
        $configurator->configure($this->generator);
108
109
        $this->assertEquals(
110
            '<meta name="twitter:site" content="@leogoutt" />',
111
            $this->generator->render()
112
        );
113
    }
114
115 View Code Duplication
    public function testNoConfig()
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...
116
    {
117
        $config = [];
118
119
        $configurator = new TwitterSeoConfigurator($config);
120
        $configurator->configure($this->generator);
121
122
        $this->assertEquals(
123
            '',
124
            $this->generator->render()
125
        );
126
    }
127
}
128