forked from ezsystems/ezpublish-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[POC - Behat] Add RepositoryContext trait (ezsystems#1584)
* [Behat] add RepositoryContext trait * Add Repository Context docs * [Behat] Repository Context methods/attributes visibility more strict
- Loading branch information
Showing
2 changed files
with
75 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
56 changes: 56 additions & 0 deletions
56
eZ/Bundle/PlatformBehatBundle/Context/RepositoryContext.php
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,56 @@ | ||
<?php | ||
/** | ||
* File containing the Repository Context class for EzBehatBundle. | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
namespace EzSystems\PlatformBehatBundle\Context; | ||
|
||
use eZ\Publish\API\Repository\Repository; | ||
use eZ\Publish\Core\Repository\Values\User\UserReference; | ||
|
||
/** | ||
* Repository Context Trait. | ||
* Everything repository related should go here. | ||
* To be used by all the other behat contexts that need the repository. | ||
* Any Context tha uses this trait will automatically login the admin user, | ||
* so any operation that needs admin permissions can be executed. | ||
*/ | ||
trait RepositoryContext | ||
{ | ||
/** | ||
* Default Administrator user id. | ||
*/ | ||
private $adminUserId = 14; | ||
|
||
/** | ||
* @var eZ\Publish\API\Repository\Repository | ||
*/ | ||
private $repository; | ||
|
||
/** | ||
* @param $repository eZ\Publish\API\Repository\Repository $repository | ||
*/ | ||
protected function setRepository(Repository $repository) | ||
{ | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* @return eZ\Publish\API\Repository\Repository $repository | ||
*/ | ||
public function getRepository() | ||
{ | ||
return $this->repository; | ||
} | ||
|
||
/** | ||
* @BeforeScenario | ||
*/ | ||
public function loginAdmin($event) | ||
{ | ||
$this->repository->setCurrentUser(new UserReference($this->adminUserId)); | ||
} | ||
} |