Completed
Push — develop ( dcf765...a9e6df )
by Léo
11s
created

OgSeoConfiguratorTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 80 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 68
loc 85
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testTitle() 14 14 1
A testDescription() 14 14 1
A testImage() 14 14 1
A testType() 14 14 1
A testNoConfig() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Tests\TestCase;
10
11
/**
12
 * Description of OgSeoConfiguratorTest.
13
 *
14
 * @author: leogout
15
 */
16
class OgSeoConfiguratorTest extends TestCase
17
{
18
    /**
19
     * @var OgSeoGenerator
20
     */
21
    protected $generator;
22
23
    protected function setUp()
24
    {
25
        $this->generator = new OgSeoGenerator(new TagBuilder(new TagFactory()));
26
    }
27
28 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...
29
    {
30
        $config = [
31
            'title' => 'Awesome | Site'
32
        ];
33
34
        $configurator = new OgSeoConfigurator($config);
35
        $configurator->configure($this->generator);
36
37
        $this->assertEquals(
38
            '<meta name="og:title" content="Awesome | Site" />',
39
            $this->generator->render()
40
        );
41
    }
42
43 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...
44
    {
45
        $config = [
46
            'description' => 'My awesome site is so cool!',
47
        ];
48
49
        $configurator = new OgSeoConfigurator($config);
50
        $configurator->configure($this->generator);
51
52
        $this->assertEquals(
53
            '<meta name="og:description" content="My awesome site is so cool!" />',
54
            $this->generator->render()
55
        );
56
    }
57
58 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...
59
    {
60
        $config = [
61
            'image' => 'http://images.com/poney/12',
62
        ];
63
64
        $configurator = new OgSeoConfigurator($config);
65
        $configurator->configure($this->generator);
66
67
        $this->assertEquals(
68
            '<meta name="og:image" content="http://images.com/poney/12" />',
69
            $this->generator->render()
70
        );
71
    }
72
73 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...
74
    {
75
        $config = [
76
            'type' => 'website',
77
        ];
78
79
        $configurator = new OgSeoConfigurator($config);
80
        $configurator->configure($this->generator);
81
82
        $this->assertEquals(
83
            '<meta name="og:type" content="website" />',
84
            $this->generator->render()
85
        );
86
    }
87
88 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...
89
    {
90
        $config = [];
91
92
        $configurator = new OgSeoConfigurator($config);
93
        $configurator->configure($this->generator);
94
95
        $this->assertEquals(
96
            '',
97
            $this->generator->render()
98
        );
99
    }
100
}
101