-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathTestContext.php
42 lines (35 loc) · 1.07 KB
/
TestContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace EzSystems\Behat\API\Context;
use Behat\Behat\Context\Context;
use eZ\Publish\API\Repository\PermissionResolver;
use eZ\Publish\API\Repository\UserService;
class TestContext implements Context
{
private $permissionResolver;
private $userService;
public function __construct(UserService $userService, PermissionResolver $permissionResolver)
{
$this->userService = $userService;
$this->permissionResolver = $permissionResolver;
}
/**
* @Given I am using the API as :username
*/
public function iAmLoggedAsApiUser(string $username)
{
$user = $this->userService->loadUserByLogin($username);
$this->permissionResolver->setCurrentUserReference($user);
}
/**
* @BeforeScenario
*/
public function loginAdminBeforeScenarioHook()
{
$this->iAmLoggedAsApiUser('admin');
}
}