-
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.
Merge branch 'main' into community-standards
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,4 @@ | |
</code-block> | ||
|
||
</article-paragraphs> | ||
|
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\BLT\Features\Traits; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use Blumilk\BLT\Features\Traits\Optional\SpatiePermission; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
trait Common | ||
{ | ||
use Eloquent; | ||
use SpatiePermission; | ||
use Authentication; | ||
use Http; | ||
|
||
/** | ||
* @Given user is in session as admin | ||
* @Given user in session has role :role | ||
*/ | ||
public function sessionHasUserWithRole(string $role = "admin"): void | ||
{ | ||
$roleArray = [ | ||
["name", $role], | ||
]; | ||
$roleTable = new TableNode($roleArray); | ||
$this->seedModelInTheDatabase("Role", $roleTable); | ||
$userArray = [ | ||
["name", $role], | ||
["email", "[email protected]"], | ||
["password", "password123!@#"], | ||
]; | ||
$userTable = new TableNode($userArray); | ||
$this->seedModelInTheDatabase("User", $userTable); | ||
|
||
$this->assignRoleTo($role, "User", "[email protected]", "email"); | ||
|
||
$this->userIsAuthenticatedInSessionAs($role, "name"); | ||
} | ||
|
||
/** | ||
* @Given admin user is getting OK response from :url | ||
* @Given admin user is getting :status status code response from :url | ||
* @Given user with :role role is getting OK response from :url | ||
* @Given user with :role role is getting :status response from :url | ||
* @Given user with :role role is getting OK response from :url using :method method | ||
* @Given user with :role role is getting :status response from :url using :method method | ||
*/ | ||
public function adminUserIsGettingResponse(string $url, string $method = "GET", int $status = Response::HTTP_OK, string $role = "admin"): void | ||
{ | ||
$this->sessionHasUserWithRole($role); | ||
$this->aUserIsRequesting($url, $method); | ||
$this->aRequestIsSent(); | ||
$this->aResponseShouldHaveStatus($status); | ||
} | ||
} |