Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class RouteCollection implements RouteCollectionInterface
{
/**
* The namespace to be added to any Controllers.
* Defaults to the global namespaces (\)
* Defaults to the global namespaces (\).
*
* This must have a trailing backslash (\).
*
* @var string
*/
Expand Down Expand Up @@ -288,7 +290,7 @@ public function __construct(FileLocator $locator, Modules $moduleConfig, Routing
$this->httpHost = Services::request()->getServer('HTTP_HOST');

// Setup based on config file. Let routes file override.
$this->defaultNamespace = $routing->defaultNamespace;
$this->defaultNamespace = rtrim($routing->defaultNamespace, '\\') . '\\';
$this->defaultController = $routing->defaultController;
$this->defaultMethod = $routing->defaultMethod;
$this->translateURIDashes = $routing->translateURIDashes;
Expand Down
13 changes: 13 additions & 0 deletions tests/system/Test/FeatureTestTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

namespace CodeIgniter\Test;

use CodeIgniter\Config\Factories;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Response;
use Config\Routing;
use Config\Services;

/**
Expand Down Expand Up @@ -616,4 +618,15 @@ public function testSetupRequestBodyWithBody(): void

$this->assertSame('test', $request->getBody());
}

public function testAutoRoutingLegacy()
{
$config = config(Routing::class);
$config->autoRoute = true;
Factories::injectMock('config', Routing::class, $config);

$response = $this->get('home/index');

$response->assertOK();
}
}