Completed
Branch master (600230)
by Andy
03:12 queued 59s
created

testGenerateUrlWithStringParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Palmtree\CanonicalUrlBundle\Tests\Service;
4
5
use Palmtree\CanonicalUrlBundle\Service\CanonicalUrlGenerator;
6
use Palmtree\CanonicalUrlBundle\Tests\AbstractTest;
7
8
class CanonicalUrlGeneratorTest extends AbstractTest
9
{
10
    /**
11
     * @dataProvider configProvider
12
     * @param array $config
13
     */
14 View Code Duplication
    public function testGenerateUrl(array $config)
1 ignored issue
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...
15
    {
16
        $urlGenerator = new CanonicalUrlGenerator($this->getRouter(), $config);
17
18
        $url = $urlGenerator->generate('foo');
19
20
        $this->assertEquals('https://example.org/foo', $url);
21
    }
22
23
    /**
24
     * @dataProvider configProvider
25
     * @param array $config
26
     */
27 View Code Duplication
    public function testGenerateUrlWithStringParams(array $config)
1 ignored issue
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...
28
    {
29
        $urlGenerator = new CanonicalUrlGenerator($this->getRouter(), $config);
30
31
        $url = $urlGenerator->generate('foo', 'key1=val1&key2=val2');
32
33
        $this->assertEquals('https://example.org/foo?key1=val1&key2=val2', $url);
34
    }
35
36
    /**
37
     * @dataProvider configProvider
38
     * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
39
     * @param array $config
40
     */
41
    public function testNonExistentRouteThrowsException(array $config)
42
    {
43
        $urlGenerator = new CanonicalUrlGenerator($this->getRouter(), $config);
44
45
        $urlGenerator->generate('bar');
46
    }
47
48
    /**
49
     * @dataProvider configProvider
50
     * @param array $config
51
     */
52 View Code Duplication
    public function testEmptyRouteReturnsEmptyString(array $config)
1 ignored issue
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...
53
    {
54
        $urlGenerator = new CanonicalUrlGenerator($this->getRouter(), $config);
55
56
        $url = $urlGenerator->generate('');
57
58
        $this->assertSame('', $url);
59
    }
60
}
61