Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#80 - add codeblocks #81

Merged
merged 4 commits into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/Features/Traits/Common.php
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);
}
}
Loading