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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
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
|
|
|
|
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.