-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5712 from kenjis/fix-spark-routes
fix: auto routes incorrectly display route filters with GET method
- Loading branch information
Showing
4 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Commands; | ||
|
||
use CodeIgniter\Test\CIUnitTestCase; | ||
use CodeIgniter\Test\Filters\CITestStreamFilter; | ||
use Config\Services; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class RoutesTest extends CIUnitTestCase | ||
{ | ||
private $streamFilter; | ||
protected $logger; | ||
protected $commands; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
CITestStreamFilter::$buffer = ''; | ||
|
||
$this->streamFilter = stream_filter_append(STDOUT, 'CITestStreamFilter'); | ||
$this->streamFilter = stream_filter_append(STDERR, 'CITestStreamFilter'); | ||
|
||
$this->logger = Services::logger(); | ||
$this->commands = Services::commands(); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
stream_filter_remove($this->streamFilter); | ||
} | ||
|
||
protected function getBuffer() | ||
{ | ||
return CITestStreamFilter::$buffer; | ||
} | ||
|
||
public function testRoutesCommand() | ||
{ | ||
command('routes'); | ||
|
||
$this->assertStringContainsString('| (Closure)', $this->getBuffer()); | ||
$this->assertStringContainsString('| Route', $this->getBuffer()); | ||
$this->assertStringContainsString('| testing', $this->getBuffer()); | ||
$this->assertStringContainsString('\\TestController::index', $this->getBuffer()); | ||
} | ||
|
||
public function testRoutesCommandRouteFilterAndAutoRoute() | ||
{ | ||
$routes = Services::routes(); | ||
$routes->resetRoutes(); | ||
$routes->get('/', 'Home::index', ['filter' => 'csrf']); | ||
|
||
command('routes'); | ||
|
||
$this->assertStringContainsString( | ||
'|auto|/|\App\Controllers\Home::index||toolbar|', | ||
str_replace(' ', '', $this->getBuffer()) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters