Skip to content

Commit 2eb3948

Browse files
committed
test: add tests for getPos()
1 parent 174f601 commit 2eb3948

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/system/Router/AutoRouterImprovedTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public function testAutoRouteFindsDefaultControllerAndMethodGet()
6464
$this->assertSame('\\' . Index::class, $controller);
6565
$this->assertSame('getIndex', $method);
6666
$this->assertSame([], $params);
67+
$this->assertSame([
68+
'controller' => null,
69+
'method' => null,
70+
'params' => null,
71+
], $router->getPos());
6772
}
6873

6974
public function testAutoRouteFindsDefaultControllerAndMethodPost()
@@ -92,6 +97,11 @@ public function testAutoRouteFindsControllerWithFileAndMethod()
9297
$this->assertSame('\\' . Mycontroller::class, $controller);
9398
$this->assertSame('getSomemethod', $method);
9499
$this->assertSame([], $params);
100+
$this->assertSame([
101+
'controller' => 0,
102+
'method' => 1,
103+
'params' => null,
104+
], $router->getPos());
95105
}
96106

97107
public function testFindsControllerAndMethodAndParam()
@@ -105,6 +115,11 @@ public function testFindsControllerAndMethodAndParam()
105115
$this->assertSame('\\' . Mycontroller::class, $controller);
106116
$this->assertSame('getSomemethod', $method);
107117
$this->assertSame(['a'], $params);
118+
$this->assertSame([
119+
'controller' => 0,
120+
'method' => 1,
121+
'params' => 2,
122+
], $router->getPos());
108123
}
109124

110125
public function testUriParamCountIsGreaterThanMethodParams()
@@ -143,6 +158,11 @@ public function testAutoRouteFindsControllerWithSubfolder()
143158
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Mycontroller::class, $controller);
144159
$this->assertSame('getSomemethod', $method);
145160
$this->assertSame([], $params);
161+
$this->assertSame([
162+
'controller' => 1,
163+
'method' => 2,
164+
'params' => null,
165+
], $router->getPos());
146166
}
147167

148168
public function testAutoRouteFindsControllerWithSubSubfolder()
@@ -224,6 +244,11 @@ public function testAutoRouteFallbackToDefaultMethod()
224244
$this->assertSame('\\' . Index::class, $controller);
225245
$this->assertSame('getIndex', $method);
226246
$this->assertSame(['15'], $params);
247+
$this->assertSame([
248+
'controller' => 0,
249+
'method' => null,
250+
'params' => 1,
251+
], $router->getPos());
227252
}
228253

229254
public function testAutoRouteFallbackToDefaultControllerOneParam()
@@ -237,6 +262,11 @@ public function testAutoRouteFallbackToDefaultControllerOneParam()
237262
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
238263
$this->assertSame('getIndex', $method);
239264
$this->assertSame(['15'], $params);
265+
$this->assertSame([
266+
'controller' => null,
267+
'method' => null,
268+
'params' => 1,
269+
], $router->getPos());
240270
}
241271

242272
public function testAutoRouteFallbackToDefaultControllerTwoParams()
@@ -250,6 +280,11 @@ public function testAutoRouteFallbackToDefaultControllerTwoParams()
250280
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
251281
$this->assertSame('getIndex', $method);
252282
$this->assertSame(['15', '20'], $params);
283+
$this->assertSame([
284+
'controller' => null,
285+
'method' => null,
286+
'params' => 1,
287+
], $router->getPos());
253288
}
254289

255290
public function testAutoRouteFallbackToDefaultControllerNoParams()
@@ -263,6 +298,11 @@ public function testAutoRouteFallbackToDefaultControllerNoParams()
263298
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
264299
$this->assertSame('getIndex', $method);
265300
$this->assertSame([], $params);
301+
$this->assertSame([
302+
'controller' => null,
303+
'method' => null,
304+
'params' => null,
305+
], $router->getPos());
266306
}
267307

268308
public function testAutoRouteRejectsSingleDot()

0 commit comments

Comments
 (0)