Completed
Push — master ( d752b0...a10eb8 )
by
unknown
04:31
created

CallbackUrlNormalizerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 5

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 tests\MediaMonks\Crawler\Url\Normalizer;
4
5
use MediaMonks\Crawler\Url;
6
use MediaMonks\Crawler\Url\Normalizer\CallbackUrlNormalizer;
7
use Mockery as m;
8
9
class CallbackUrlNormalizerTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function test_callback_is_called()
12
    {
13
        $callback = function(Url $url) {
14
            $url->__toString();
15
        };
16
17
        $url = m::mock(Url::class);
18
        $url->shouldReceive('__toString')->once();
19
20
        $callbackUrlMatcher = new CallbackUrlNormalizer($callback);
21
        $callbackUrlMatcher->normalize($url);
22
    }
23
24
    protected function tearDown()
25
    {
26
        parent::tearDown();
27
28
        m::close();
29
    }
30
}