Test Setup Failed
Push — master ( ecdc34...0769f8 )
by Gabriel
02:46 queued 11s
created

test_generateStandardRoute_emptyClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Router\Tests\RouteFactory;
4
5
use Nip\Router\Route\LiteralRoute;
6
use Nip\Router\Route\StandardRoute;
7
use Nip\Router\RouteCollection;
8
use Nip\Router\RouteFactory;
9
use Nip\Router\Tests\AbstractTest;
10
use Nip\Router\Tests\Fixtures\Application\Library\Router\Route\LiteralRoute as FixturesLiteralRoute;
11
use Nip\Router\Tests\Fixtures\Application\Library\Router\Route\StandardRoute as FixturesStandardRoute;
12
13
/**
14
 * Class HasBaseRoutesTraitTest
15
 * @package Nip\Router\Tests\RouteFactory
16
 */
17
class HasBaseRoutesTraitTest extends AbstractTest
18
{
19 View Code Duplication
    public function test_generateIndexRoute_emptyClass()
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...
20
    {
21
        $collection = new RouteCollection();
22
        RouteFactory::generateIndexRoute($collection, 'index');
23
24
        self::assertCount(2, $collection);
25
26
        $firstRoute = $collection->get('index');
27
        self::assertInstanceOf(LiteralRoute::class, $firstRoute);
28
        self::assertSame('/', $firstRoute->getParser()->getMap());
29
        self::assertSame(["controller" => "index", "action" => "index"], $firstRoute->getDefaults());
30
    }
31
32 View Code Duplication
    public function test_generateIndexRoute_existingClass()
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...
33
    {
34
        $collection = new RouteCollection();
35
        RouteFactory::generateIndexRoute($collection, 'index', FixturesLiteralRoute::class);
36
37
        self::assertCount(2, $collection);
38
39
        $firstRoute = $collection->get('index');
40
        self::assertInstanceOf(FixturesLiteralRoute::class, $firstRoute);
41
    }
42
43 View Code Duplication
    public function test_generateIndexRoute_nonClass()
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
        $collection = new RouteCollection();
46
        RouteFactory::generateIndexRoute($collection, 'index', 'MyApplication\Module\Route\LiteralRoute');
47
48
        self::assertCount(2, $collection);
49
50
        $firstRoute = $collection->get('index');
51
        self::assertInstanceOf(LiteralRoute::class, $firstRoute);
52
    }
53
54
55 View Code Duplication
    public function test_generateStandardRoute_emptyClass()
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
        $collection = new RouteCollection();
58
        RouteFactory::generateStandardRoute($collection, 'index');
59
60
        self::assertCount(2, $collection);
61
62
        $firstRoute = $collection->get('index');
63
        self::assertInstanceOf(StandardRoute::class, $firstRoute);
64
        self::assertSame('/{controller}/{action?index}', $firstRoute->getParser()->getMap());
65
        self::assertSame(["action" => "index"], $firstRoute->getDefaults());
66
    }
67
68 View Code Duplication
    public function test_generateStandardRoute_existingClass()
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...
69
    {
70
        $collection = new RouteCollection();
71
        RouteFactory::generateStandardRoute($collection, 'index', FixturesStandardRoute::class);
72
73
        self::assertCount(2, $collection);
74
75
        $firstRoute = $collection->get('index');
76
        self::assertInstanceOf(FixturesStandardRoute::class, $firstRoute);
77
    }
78
79 View Code Duplication
    public function test_generateStandardRoute_nonClass()
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...
80
    {
81
        $collection = new RouteCollection();
82
        RouteFactory::generateStandardRoute($collection, 'index', 'MyApplication\Module\Route\StandardRoute');
83
84
        self::assertCount(2, $collection);
85
86
        $firstRoute = $collection->get('index');
87
        self::assertInstanceOf(StandardRoute::class, $firstRoute);
88
    }
89
}
90