-
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.
Add helper class with test assertions.
- Loading branch information
1 parent
7ab5e5a
commit d050da7
Showing
3 changed files
with
110 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,67 @@ | ||
<?php | ||
|
||
namespace Gbuckingham89\Laraflash; | ||
|
||
use Illuminate\Testing\TestResponse; | ||
|
||
abstract class LaraflashAssertions | ||
{ | ||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
*/ | ||
public static function assertResponseDoesntHaveLaraflash(TestResponse $response): void | ||
{ | ||
$response->assertSessionMissing('laraflash.level'); | ||
$response->assertSessionMissing('laraflash.message'); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
* @param string $level | ||
* @param string|null $message | ||
*/ | ||
public static function assertResponseHasLaraflash( | ||
TestResponse $response, | ||
string $level, | ||
?string $message = null | ||
): void { | ||
$response->assertSessionHas('laraflash.level', $level); | ||
$response->assertSessionHas('laraflash.message', $message); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
* @param string|null $message | ||
*/ | ||
public static function assertResponseHasLaraflashSuccess(TestResponse $response, ?string $message = null): void | ||
{ | ||
self::assertResponseHasLaraflash($response, 'success', $message); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
* @param string|null $message | ||
*/ | ||
public static function assertResponseHasLaraflashInfo(TestResponse $response, ?string $message = null): void | ||
{ | ||
self::assertResponseHasLaraflash($response, 'info', $message); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
* @param string|null $message | ||
*/ | ||
public static function assertResponseHasLaraflashWarning(TestResponse $response, ?string $message = null): void | ||
{ | ||
self::assertResponseHasLaraflash($response, 'warning', $message); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Testing\TestResponse $response | ||
* @param string|null $message | ||
*/ | ||
public static function assertResponseHasLaraflashDanger(TestResponse $response, ?string $message = null): void | ||
{ | ||
self::assertResponseHasLaraflash($response, 'danger', $message); | ||
} | ||
} |