1 | <?php |
||||
2 | |||||
3 | |||||
4 | namespace Nip\Router\Tests\Parsers; |
||||
5 | |||||
6 | use Nip\Router\Parsers\Standard; |
||||
7 | |||||
8 | /** |
||||
9 | * Test class for Nip_Route_Abstract. |
||||
10 | * Generated by PHPUnit on 2010-11-17 at 15:16:44. |
||||
11 | */ |
||||
12 | class StandardTest extends \Nip\Router\Tests\AbstractTest |
||||
13 | { |
||||
14 | |||||
15 | /** |
||||
16 | * @var Standard |
||||
17 | */ |
||||
18 | protected $object; |
||||
19 | |||||
20 | /** |
||||
21 | * Sets up the fixture, for example, opens a network connection. |
||||
22 | * This method is called before a test is executed. |
||||
23 | */ |
||||
24 | protected function setUp() : void |
||||
25 | { |
||||
26 | parent::setUp(); |
||||
27 | $this->object = new Standard(); |
||||
28 | } |
||||
29 | |||||
30 | public function testAssemble() |
||||
31 | { |
||||
32 | $params = [ |
||||
33 | 'controller' => 'lorem', |
||||
34 | 'action' => 'ipsum', |
||||
35 | 'company' => 'dolo&rem', |
||||
36 | ]; |
||||
37 | static::assertEquals('lorem/ipsum?company=dolo%26rem', $this->object->assemble($params)); |
||||
38 | |||||
39 | $this->object->setMap('admin/:controller/:action'); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
40 | static::assertEquals('admin/lorem/ipsum?company=dolo%26rem', $this->object->assemble($params)); |
||||
41 | |||||
42 | unset($params['action']); |
||||
43 | static::assertEquals('admin/lorem/?company=dolo%26rem', $this->object->assemble($params)); |
||||
44 | } |
||||
45 | |||||
46 | public function testMatch() |
||||
47 | { |
||||
48 | static::assertFalse($this->object->match('shop/category_cast/asdasd')); |
||||
49 | static::assertTrue($this->object->match('shop/category_cast/')); |
||||
50 | |||||
51 | static::assertTrue($this->object->match('shop/cart')); |
||||
52 | static::assertEquals(array('controller' => 'shop', 'action' => 'cart'), $this->object->getParams()); |
||||
53 | |||||
54 | static::assertTrue($this->object->match('shop/')); |
||||
55 | static::assertEquals(array('controller' => 'shop', 'action' => ''), $this->object->getParams()); |
||||
56 | |||||
57 | static::assertTrue($this->object->match('shop')); |
||||
58 | static::assertEquals(array('controller' => 'shop', 'action' => ''), $this->object->getParams()); |
||||
59 | } |
||||
60 | |||||
61 | public function testMatchCustom() |
||||
62 | { |
||||
63 | $this->object->setMap('admin/:controller/:action'); |
||||
0 ignored issues
–
show
'admin/:controller/:action' of type string is incompatible with the type boolean expected by parameter $map of Nip\Router\Parsers\AbstractParser::setMap() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
64 | |||||
65 | static::assertFalse($this->object->match('shop/category_cast/asdasd')); |
||||
66 | static::assertFalse($this->object->match('shop/category_cast/')); |
||||
67 | |||||
68 | static::assertFalse($this->object->match('admin/test/asd/category_cast/')); |
||||
69 | |||||
70 | static::assertTrue($this->object->match('admin/shop/cart')); |
||||
71 | static::assertEquals(array('controller' => 'shop', 'action' => 'cart'), $this->object->getParams()); |
||||
72 | |||||
73 | static::assertTrue($this->object->match('admin/shop/')); |
||||
74 | static::assertEquals(array('controller' => 'shop', 'action' => ''), $this->object->getParams()); |
||||
75 | |||||
76 | static::assertTrue($this->object->match('admin/shop')); |
||||
77 | static::assertEquals(array('controller' => 'shop', 'action' => ''), $this->object->getParams()); |
||||
78 | } |
||||
79 | } |
||||
80 |