OgSeoConfiguratorTest::testImage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Tests\Seo\Og;
4
5
use Leogout\Bundle\SeoBundle\Builder\TagBuilder;
6
use Leogout\Bundle\SeoBundle\Factory\TagFactory;
7
use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoConfigurator;
8
use Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator;
9
use Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoGenerator;
10
use Leogout\Bundle\SeoBundle\Tests\TestCase;
11
12
/**
13
 * Description of OgSeoConfiguratorTest.
14
 *
15
 * @author: leogout
16
 */
17
class OgSeoConfiguratorTest extends TestCase
18
{
19
    /**
20
     * @var OgSeoGenerator
21
     */
22
    protected $generator;
23
24
    protected function setUp()
25
    {
26
        $this->generator = new OgSeoGenerator(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\Og\OgSeoConfigurator. Expected "Leogout\Bundle\SeoBundle\Seo\Og\OgSeoGenerator", but got "Leogout\Bundle\SeoBundle\Seo\Twitter\TwitterSeoGenerator".
32
     */
33
    public function testException()
34
    {
35
        $invalidGenerator = new TwitterSeoGenerator(new TagBuilder(new TagFactory()));
36
        $configurator = new OgSeoConfigurator([]);
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 OgSeoConfigurator($config);
47
        $configurator->configure($this->generator);
48
49
        $this->assertEquals(
50
            '<meta name="og: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 OgSeoConfigurator($config);
62
        $configurator->configure($this->generator);
63
64
        $this->assertEquals(
65
            '<meta name="og: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 OgSeoConfigurator($config);
77
        $configurator->configure($this->generator);
78
79
        $this->assertEquals(
80
            '<meta name="og:image" content="http://images.com/poney/12" />',
81
            $this->generator->render()
82
        );
83
    }
84
85 View Code Duplication
    public function testType()
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
            'type' => 'website',
89
        ];
90
91
        $configurator = new OgSeoConfigurator($config);
92
        $configurator->configure($this->generator);
93
94
        $this->assertEquals(
95
            '<meta name="og:type" content="website" />',
96
            $this->generator->render()
97
        );
98
    }
99
100 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...
101
    {
102
        $config = [];
103
104
        $configurator = new OgSeoConfigurator($config);
105
        $configurator->configure($this->generator);
106
107
        $this->assertEquals(
108
            '',
109
            $this->generator->render()
110
        );
111
    }
112
}
113