Completed
Push — travis_trusty ( e78e49...6f0d6f )
by André
54:54 queued 34:46
created

RepositoryContext::getRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 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;
0 ignored issues
show
Documentation Bug introduced by
It seems like $repository of type object<eZ\Publish\API\Repository\Repository> is incompatible with the declared type object<EzSystems\Platfor...\Repository\Repository> of property $repository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
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