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

HasModulesRoutesTraitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 88.37 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 38
loc 43
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_generateGenericModuleDefaultRoutes_no_namespace() 12 12 1
A test_generateGenericModuleDefaultRoutes_with_namespace() 13 13 1
A test_generateGenericModuleDefaultRoutes_with_namespace_missing_classes() 13 13 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 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\Modules\Admin\Routes\LiteralRoute as AdminLiteralRoute;
11
use Nip\Router\Tests\Fixtures\Application\Modules\Admin\Routes\StandardRoute as AdminStandardRoute;
12
13
/**
14
 * Class HasModulesRoutesTraitTest
15
 * @package Nip\Router\Tests\RouteFactory
16
 */
17
class HasModulesRoutesTraitTest extends AbstractTest
18
{
19 View Code Duplication
    public function test_generateGenericModuleDefaultRoutes_no_namespace()
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::generateGenericModuleDefaultRoutes($collection, "admin", '/admin');
23
24
        self::assertCount(4, $collection);
25
26
        self::assertInstanceOf(LiteralRoute::class, $collection->get('admin.slash'));
27
        self::assertInstanceOf(LiteralRoute::class, $collection->get('admin'));
28
        self::assertInstanceOf(StandardRoute::class, $collection->get('admin.default'));
29
        self::assertInstanceOf(StandardRoute::class, $collection->get('admin.default.index'));
30
    }
31
32 View Code Duplication
    public function test_generateGenericModuleDefaultRoutes_with_namespace()
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::generateGenericModuleDefaultRoutes($collection,
36
            ["admin", "Nip\Router\Tests\Fixtures\Application\\"], '/admin');
37
38
        self::assertCount(4, $collection);
39
40
        self::assertInstanceOf(AdminLiteralRoute::class, $collection->get('admin.slash'));
41
        self::assertInstanceOf(AdminLiteralRoute::class, $collection->get('admin'));
42
        self::assertInstanceOf(AdminStandardRoute::class, $collection->get('admin.default'));
43
        self::assertInstanceOf(AdminStandardRoute::class, $collection->get('admin.default.index'));
44
    }
45
46 View Code Duplication
    public function test_generateGenericModuleDefaultRoutes_with_namespace_missing_classes()
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...
47
    {
48
        $collection = new RouteCollection();
49
        RouteFactory::generateGenericModuleDefaultRoutes($collection,
50
            ["frontend", "Nip\Router\Tests\Fixtures\Application\\"], '/admin');
51
52
        self::assertCount(4, $collection);
53
54
        self::assertInstanceOf(LiteralRoute::class, $collection->get('frontend.slash'));
55
        self::assertInstanceOf(LiteralRoute::class, $collection->get('frontend'));
56
        self::assertInstanceOf(StandardRoute::class, $collection->get('frontend.default'));
57
        self::assertInstanceOf(StandardRoute::class, $collection->get('frontend.default.index'));
58
    }
59
}
60