forked from apiato/apiato
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0416e19
commit 68919bb
Showing
2 changed files
with
21 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
use App\Containers\AppSection\User\Actions\CreateAdminAction; | ||
use App\Containers\AppSection\User\Tests\TestCase; | ||
use Exception; | ||
|
||
/** | ||
* Class CreateAdminActionTest. | ||
|
@@ -27,4 +28,23 @@ public function testCreateAdmin(): void | |
$this->assertTrue($admin->hasRole(config('appSection-authorization.admin_role'))); | ||
$this->assertNotNull($admin->email_verified_at); | ||
} | ||
|
||
public function testGivenInvalidData_ThrowExceptionAndRollbackAllCommits(): void | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
// update Admin role name to a not existing role (different from what is seeded for admin role), | ||
// so we can get an error | ||
config(['appSection-authorization.admin_role' => 'not_existing_role']); | ||
|
||
$data = [ | ||
'email' => '[email protected]', | ||
'password' => 'admin', | ||
'name' => 'Super Admin', | ||
]; | ||
|
||
$admin = app(CreateAdminAction::class)->run($data); | ||
|
||
$this->assertModelMissing($admin); | ||
} | ||
} |