Completed
Push — test-EZP-26707-issearchable-fu... ( 774d65...d743e2 )
by
unknown
24:59
created

RepositoryContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 36
rs 10
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setRepository() 0 4 1
A getRepository() 0 4 1
A loginAdmin() 0 4 1
1
<?php
2
/**
3
 * File containing the Repository Context class for EzBehatBundle.
4
 *
5
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
6
 * @license For full copyright and license information view LICENSE file distributed with this source code.
7
 * @version //autogentag//
8
 */
9
namespace EzSystems\PlatformBehatBundle\Context;
10
11
use eZ\Publish\API\Repository\Repository;
12
use eZ\Publish\Core\Repository\Values\User\UserReference;
13
14
/**
15
 * Repository Context Trait.
16
 * Everything repository related should go here.
17
 * To be used by all the other behat contexts that need the repository.
18
 * Any Context tha uses this trait will automatically login the admin user,
19
 * so any operation that needs admin permissions can be executed.
20
 */
21
trait RepositoryContext
22
{
23
    /**
24
     * Default Administrator user id.
25
     */
26
    private $adminUserId = 14;
27
28
    /**
29
     * @var \eZ\Publish\API\Repository\Repository
30
     */
31
    private $repository;
32
33
    /**
34
     * @param $repository \eZ\Publish\API\Repository\Repository $repository
35
     */
36
    protected function setRepository(Repository $repository)
37
    {
38
        $this->repository = $repository;
39
    }
40
41
    /**
42
     * @return \eZ\Publish\API\Repository\Repository $repository
43
     */
44
    public function getRepository()
45
    {
46
        return $this->repository;
47
    }
48
49
    /**
50
     * @BeforeScenario
51
     */
52
    public function loginAdmin($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        $this->repository->setCurrentUser(new UserReference($this->adminUserId));
55
    }
56
}
57