Skip to content

Commit 28350f3

Browse files
committed
test: add tests for getPos()
1 parent b0d6f2c commit 28350f3

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
@@ -65,6 +65,11 @@ public function testAutoRouteFindsDefaultControllerAndMethodGet()
6565
$this->assertSame('\\' . Index::class, $controller);
6666
$this->assertSame('getIndex', $method);
6767
$this->assertSame([], $params);
68+
$this->assertSame([
69+
'controller' => null,
70+
'method' => null,
71+
'params' => null,
72+
], $router->getPos());
6873
}
6974

7075
public function testAutoRouteFindsModuleDefaultControllerAndMethodGet()
@@ -114,6 +119,11 @@ public function testAutoRouteFindsControllerWithFileAndMethod()
114119
$this->assertSame('\\' . Mycontroller::class, $controller);
115120
$this->assertSame('getSomemethod', $method);
116121
$this->assertSame([], $params);
122+
$this->assertSame([
123+
'controller' => 0,
124+
'method' => 1,
125+
'params' => null,
126+
], $router->getPos());
117127
}
118128

119129
public function testFindsControllerAndMethodAndParam()
@@ -127,6 +137,11 @@ public function testFindsControllerAndMethodAndParam()
127137
$this->assertSame('\\' . Mycontroller::class, $controller);
128138
$this->assertSame('getSomemethod', $method);
129139
$this->assertSame(['a'], $params);
140+
$this->assertSame([
141+
'controller' => 0,
142+
'method' => 1,
143+
'params' => 2,
144+
], $router->getPos());
130145
}
131146

132147
public function testUriParamCountIsGreaterThanMethodParams()
@@ -165,6 +180,11 @@ public function testAutoRouteFindsControllerWithSubfolder()
165180
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Mycontroller::class, $controller);
166181
$this->assertSame('getSomemethod', $method);
167182
$this->assertSame([], $params);
183+
$this->assertSame([
184+
'controller' => 1,
185+
'method' => 2,
186+
'params' => null,
187+
], $router->getPos());
168188
}
169189

170190
public function testAutoRouteFindsControllerWithSubSubfolder()
@@ -246,6 +266,11 @@ public function testAutoRouteFallbackToDefaultMethod()
246266
$this->assertSame('\\' . Index::class, $controller);
247267
$this->assertSame('getIndex', $method);
248268
$this->assertSame(['15'], $params);
269+
$this->assertSame([
270+
'controller' => 0,
271+
'method' => null,
272+
'params' => 1,
273+
], $router->getPos());
249274
}
250275

251276
public function testAutoRouteFallbackToDefaultControllerOneParam()
@@ -259,6 +284,11 @@ public function testAutoRouteFallbackToDefaultControllerOneParam()
259284
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
260285
$this->assertSame('getIndex', $method);
261286
$this->assertSame(['15'], $params);
287+
$this->assertSame([
288+
'controller' => null,
289+
'method' => null,
290+
'params' => 1,
291+
], $router->getPos());
262292
}
263293

264294
public function testAutoRouteFallbackToDefaultControllerTwoParams()
@@ -272,6 +302,11 @@ public function testAutoRouteFallbackToDefaultControllerTwoParams()
272302
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
273303
$this->assertSame('getIndex', $method);
274304
$this->assertSame(['15', '20'], $params);
305+
$this->assertSame([
306+
'controller' => null,
307+
'method' => null,
308+
'params' => 1,
309+
], $router->getPos());
275310
}
276311

277312
public function testAutoRouteFallbackToDefaultControllerNoParams()
@@ -285,6 +320,11 @@ public function testAutoRouteFallbackToDefaultControllerNoParams()
285320
$this->assertSame('\\' . \CodeIgniter\Router\Controllers\Subfolder\Home::class, $controller);
286321
$this->assertSame('getIndex', $method);
287322
$this->assertSame([], $params);
323+
$this->assertSame([
324+
'controller' => null,
325+
'method' => null,
326+
'params' => null,
327+
], $router->getPos());
288328
}
289329

290330
public function testAutoRouteRejectsSingleDot()

0 commit comments

Comments
 (0)