Skip to content

Commit

Permalink
test: fix some test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
ping-yee committed Oct 9, 2023
1 parent bc31b56 commit 29b7f8c
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions tests/system/Router/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,28 @@ public function testAutoRouteFindsControllerWithFileAndMethod(): void
$this->collection->setAutoRoute(true);
$router = new Router($this->collection, $this->request);

$router->autoRoute('myController/someMethod');
copy(TESTPATH . 'system/Router/Controllers/MyController.php', APPPATH . 'Controllers/Mycontroller.php');

$this->assertSame('MyController', $router->controllerName());
$this->assertSame('someMethod', $router->methodName());
$router->autoRoute('Mycontroller/getSomemethod');

unlink(APPPATH . 'Controllers/Mycontroller.php');

$this->assertSame('Mycontroller', $router->controllerName());
$this->assertSame('getSomemethod', $router->methodName());
}

public function testAutoRouteFindsControllerWithFile(): void
{
$this->collection->setAutoRoute(true);
$router = new Router($this->collection, $this->request);

$router->autoRoute('myController');
copy(TESTPATH . 'system/Router/Controllers/MyController.php', APPPATH . 'Controllers/Mycontroller.php');

$this->assertSame('MyController', $router->controllerName());
$router->autoRoute('mycontroller');

unlink(APPPATH . 'Controllers/Mycontroller.php');

$this->assertSame('Mycontroller', $router->controllerName());
$this->assertSame('index', $router->methodName());
}

Expand All @@ -236,12 +244,16 @@ public function testAutoRouteFindsControllerWithSubfolder(): void

mkdir(APPPATH . 'Controllers/Subfolder');

$router->autoRoute('subfolder/myController/someMethod');
copy(TESTPATH . 'system/Router/Controllers/Subfolder/MyController.php', APPPATH . 'Controllers/Subfolder/Mycontroller.php');

$router->autoRoute('subfolder/Mycontroller/getSomemethod');

unlink(APPPATH . 'Controllers/Subfolder/Mycontroller.php');

rmdir(APPPATH . 'Controllers/Subfolder');

$this->assertSame('MyController', $router->controllerName());
$this->assertSame('someMethod', $router->methodName());
$this->assertSame('Mycontroller', $router->controllerName());
$this->assertSame('getSomemethod', $router->methodName());
}

public function testAutoRouteFindsDashedSubfolder(): void
Expand Down

0 comments on commit 29b7f8c

Please sign in to comment.