diff --git a/system/Test/bootstrap.php b/system/Test/bootstrap.php index 8fde5408e92c..4a217fef12e7 100644 --- a/system/Test/bootstrap.php +++ b/system/Test/bootstrap.php @@ -13,14 +13,14 @@ $paths = new Config\Paths(); // Define necessary framework path constants -defined('APPPATH') || define('APPPATH', realpath($paths->appDirectory) . DIRECTORY_SEPARATOR); -defined('WRITEPATH') || define('WRITEPATH', realpath($paths->writableDirectory) . DIRECTORY_SEPARATOR); -defined('SYSTEMPATH') || define('SYSTEMPATH', realpath($paths->systemDirectory) . DIRECTORY_SEPARATOR); -defined('ROOTPATH') || define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR); -defined('CIPATH') || define('CIPATH', realpath(SYSTEMPATH . '../') . DIRECTORY_SEPARATOR); -defined('FCPATH') || define('FCPATH', realpath(PUBLICPATH) . DIRECTORY_SEPARATOR); -defined('TESTPATH') || define('TESTPATH', realpath(HOMEPATH . 'tests/') . DIRECTORY_SEPARATOR); -defined('SUPPORTPATH') || define('SUPPORTPATH', realpath(TESTPATH . '_support/') . DIRECTORY_SEPARATOR); +defined('APPPATH') || define('APPPATH', realpath($paths->appDirectory) . DIRECTORY_SEPARATOR); +defined('WRITEPATH') || define('WRITEPATH', realpath($paths->writableDirectory) . DIRECTORY_SEPARATOR); +defined('SYSTEMPATH') || define('SYSTEMPATH', realpath($paths->systemDirectory) . DIRECTORY_SEPARATOR); +defined('ROOTPATH') || define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR); +defined('CIPATH') || define('CIPATH', realpath(SYSTEMPATH . '../') . DIRECTORY_SEPARATOR); +defined('FCPATH') || define('FCPATH', realpath(PUBLICPATH) . DIRECTORY_SEPARATOR); +defined('TESTPATH') || define('TESTPATH', realpath(HOMEPATH . 'tests/') . DIRECTORY_SEPARATOR); +defined('SUPPORTPATH') || define('SUPPORTPATH', realpath(TESTPATH . '_support/') . DIRECTORY_SEPARATOR); defined('COMPOSER_PATH') || define('COMPOSER_PATH', realpath(HOMEPATH . 'vendor/autoload.php')); // Load Common.php from App then System @@ -58,3 +58,6 @@ class_alias('Config\Services', 'CodeIgniter\Services'); // Register the loader with the SPL autoloader stack. $loader->register(); + +require_once APPPATH . 'Config/Routes.php'; +$routes->getRoutes('*'); diff --git a/tests/_support/Config/Routes.php b/tests/_support/Config/Routes.php index 2369e33b22b7..8102b4a95ae1 100644 --- a/tests/_support/Config/Routes.php +++ b/tests/_support/Config/Routes.php @@ -4,4 +4,4 @@ * This is a simple file to include for testing the RouteCollection class. */ -$routes->add('testing', 'TestController::index'); +$routes->add('testing', 'TestController::index', ['as' => 'testing-index']); diff --git a/tests/_support/Controllers/Popcorn.php b/tests/_support/Controllers/Popcorn.php index 8af998d87d53..a25ce436060a 100644 --- a/tests/_support/Controllers/Popcorn.php +++ b/tests/_support/Controllers/Popcorn.php @@ -74,4 +74,9 @@ public function xml() $this->respond('cat'); } + public function toindex() + { + return redirect()->route('testing-index'); + } + } diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 407944f758e1..0b8fa200c318 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -1118,7 +1118,7 @@ public function testDiscoverLocalAllowsConfigToOverridePackages() $routes = $this->getCollector($config, [], $moduleConfig); - $routes->add('testing', 'MainRoutes::index'); + $routes->add('testing', 'MainRoutes::index', ['as' => 'testing-index']); $match = $routes->getRoutes(); diff --git a/tests/system/Test/ControllerTesterTest.php b/tests/system/Test/ControllerTesterTest.php index 909665c10333..4d19694c6cb6 100644 --- a/tests/system/Test/ControllerTesterTest.php +++ b/tests/system/Test/ControllerTesterTest.php @@ -228,4 +228,11 @@ public function testControllerNoURI() $this->assertTrue($result->isOK()); } + public function testRedirectRoute() + { + $result = $this->controller(\Tests\Support\Controllers\Popcorn::class) + ->execute('toindex'); + $this->assertTrue($result->isRedirect()); + } + } diff --git a/tests/system/Test/FeatureTestCaseTest.php b/tests/system/Test/FeatureTestCaseTest.php index 0077c0e6d0ba..52e4b0ee45a3 100644 --- a/tests/system/Test/FeatureTestCaseTest.php +++ b/tests/system/Test/FeatureTestCaseTest.php @@ -161,7 +161,7 @@ public function testReturns() [ 'get', 'home', - 'Tests\Support\Controllers\Popcorn::index', + '\Tests\Support\Controllers\Popcorn::index', ], ]); $response = $this->get('home'); @@ -174,7 +174,7 @@ public function testIgnores() [ 'get', 'home', - 'Tests\Support\Controllers\Popcorn::cat', + '\Tests\Support\Controllers\Popcorn::cat', ], ]); $response = $this->get('home'); @@ -187,7 +187,7 @@ public function testEchoes() [ 'get', 'home', - 'Tests\Support\Controllers\Popcorn::canyon', + '\Tests\Support\Controllers\Popcorn::canyon', ], ]); ob_start();