Completed
Push — master ( 0fd1e7...aad679 )
by Jérémy
02:00
created

OpenGraphExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 90 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 45
loc 50
rs 10

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 Novaway\Bundle\OpenGraphBundle\Tests\Units\Twig;
4
5
use atoum;
6
7
class OpenGraphExtension extends atoum
8
{
9
    public function testRenderNamespaceAttributesFunction()
10
    {
11
        $this
12
            ->given(
13
                $renderer = new \mock\Novaway\Component\OpenGraph\View\OpenGraphRendererInterface(),
14
                $graph = new \mock\Novaway\Component\OpenGraph\OpenGraphInterface()
15
            )
16
            ->if($this->newTestedInstance($renderer))
17
            ->then
18
                ->given($this->testedInstance->renderNamespaceFunction($graph))
19
                ->mock($renderer)
20
                    ->call('renderNamespaceAttributes')
21
                        ->withAtLeastArguments([$graph])->once()
22
        ;
23
    }
24
25
    public function testRenderGraphFunction()
26
    {
27
        $this
28
            ->given(
29
                $renderer = new \mock\Novaway\Component\OpenGraph\View\OpenGraphRendererInterface(),
30
                $graph = new \mock\Novaway\Component\OpenGraph\OpenGraphInterface()
31
            )
32
            ->if($this->newTestedInstance($renderer))
33
            ->then
34
                ->given($this->testedInstance->renderGraphFunction($graph))
35
                    ->mock($renderer)
36
                        ->call('render')
37
                            ->withAtLeastArguments([$graph])->once()
38
        ;
39
    }
40
41
    public function testRenderTagFunction()
42
    {
43
        $this
44
            ->given(
45
                $renderer = new \mock\Novaway\Component\OpenGraph\View\OpenGraphRendererInterface(),
46
                $tag = new \mock\Novaway\Component\OpenGraph\OpenGraphTagInterface()
47
            )
48
            ->if($this->newTestedInstance($renderer))
49
            ->then
50
                ->given($this->testedInstance->renderTagFunction($tag))
51
                    ->mock($renderer)
52
                        ->call('renderTag')
53
                            ->withAtLeastArguments([$tag])->once()
54
        ;
55
    }
56
}
57
58