From effc541e13d27e73860df47699d119bea5d84b31 Mon Sep 17 00:00:00 2001 From: mohammad-alavi Date: Fri, 1 Oct 2021 20:33:30 +0330 Subject: [PATCH] add test --- .../UI/API/Tests/Functional/CreateRoleTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Containers/AppSection/Authorization/UI/API/Tests/Functional/CreateRoleTest.php b/app/Containers/AppSection/Authorization/UI/API/Tests/Functional/CreateRoleTest.php index 768972525..5e971a28d 100644 --- a/app/Containers/AppSection/Authorization/UI/API/Tests/Functional/CreateRoleTest.php +++ b/app/Containers/AppSection/Authorization/UI/API/Tests/Functional/CreateRoleTest.php @@ -3,6 +3,7 @@ namespace App\Containers\AppSection\Authorization\UI\API\Tests\Functional; use App\Containers\AppSection\Authorization\UI\API\Tests\ApiTestCase; +use Illuminate\Testing\Fluent\AssertableJson; /** * Class CreateRoleTest. @@ -45,5 +46,20 @@ public function testCreateRoleWithWrongName(): void $response = $this->makeCall($data); $response->assertStatus(422); + $response->assertJson( + fn (AssertableJson $json) => + $json->has('message') + ->has('errors') + ->where('errors.name.0.0', 'String should not contain space.') + ); + } + + public function testGivenHaveNoAccess_CannotCreateRole(): void + { + $this->getTestingUserWithoutAccess(); + + $response = $this->makeCall([]); + + $response->assertStatus(403); } }