-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5d1248
commit 5f91255
Showing
4 changed files
with
93 additions
and
2 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
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,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace System\Test\Integrate\Helper; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use System\Integrate\Testing\TestResponse; | ||
use System\Router\Router; | ||
|
||
final class RedirectResponseTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function itRiderectToCorrectUrl() | ||
{ | ||
Router::get('/test/(:any)', fn ($test) => $test)->name('test'); | ||
$redirect = redirect_route('test', ['ok']); | ||
$res = new TestResponse($redirect); | ||
$res->assertStatusCode(302); | ||
|
||
Router::reset(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itRiderectToCorrectUrlWithPlanUrl() | ||
{ | ||
Router::get('/test', fn ($test) => $test)->name('test'); | ||
$redirect = redirect_route('test'); | ||
$res = new TestResponse($redirect); | ||
$res->assertStatusCode(302); | ||
|
||
Router::reset(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itThrowErrorWhenPatternNotExist() | ||
{ | ||
Router::get('/test/(:test)', fn ($test) => $test)->name('test'); | ||
$message = ''; | ||
try { | ||
redirect_route('test', ['test']); | ||
} catch (\Throwable $th) { | ||
$message = $th->getMessage(); | ||
} | ||
$this->assertEquals('parameter not matches with any pattern.', $message); | ||
|
||
Router::reset(); | ||
} | ||
} |