Skip to content

Commit

Permalink
Changed API user to admin by default (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnocon authored Aug 17, 2022
1 parent b97334d commit b93437c
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/lib/API/Context/TestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace EzSystems\Behat\API\Context;

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use eZ\Publish\API\Repository\PermissionResolver;
use eZ\Publish\API\Repository\UserService;

Expand All @@ -27,32 +26,17 @@ public function __construct(UserService $userService, PermissionResolver $permis
/**
* @Given I am using the API as :username
*/
public function iAmLoggedAsUser(string $username)
public function iAmLoggedAsApiUser(string $username)
{
$user = $this->userService->loadUserByLogin($username);
$this->permissionResolver->setCurrentUserReference($user);
}

/**
* @BeforeScenario @admin
*/
public function loginAdminBeforeScenarioHook()
{
$this->iAmLoggedAsUser('admin');
}

/**
* @BeforeScenario
*/
public function loginAPIUser(BeforeScenarioScope $scope)
public function loginAdminBeforeScenarioHook()
{
$tags = $scope->getScenario()->getTags();
foreach ($tags as $tag) {
if (0 === strpos($tag, 'APIUser:')) {
$this->iAmLoggedAsUser(explode(':', $tag)[1]);

return;
}
}
$this->iAmLoggedAsApiUser('admin');
}
}

0 comments on commit b93437c

Please sign in to comment.