Completed
Push — master ( d11e08...dcc2fa )
by Christian
02:22
created

StatementRepositoryTest::createRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace XApi\Repository\Doctrine\Test\Functional;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use XApi\Repository\Api\Test\Functional\StatementRepositoryTest as BaseStatementRepositoryTest;
16
use XApi\Repository\Doctrine\Repository\MappedStatementRepository;
17
use XApi\Repository\Doctrine\Repository\StatementRepository;
18
19
/**
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
abstract class StatementRepositoryTest extends BaseStatementRepositoryTest
23
{
24
    /**
25
     * @var ObjectManager
26
     */
27
    protected $objectManager;
28
29
    /**
30
     * @var MappedStatementRepository
31
     */
32
    protected $repository;
33
34
    protected function setUp()
35
    {
36
        $this->objectManager = $this->createObjectManager();
37
        $this->repository = $this->createRepository();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createRepository() of type object<Doctrine\Common\P...tence\ObjectRepository> is incompatible with the declared type object<XApi\Repository\D...pedStatementRepository> 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...
38
39
        parent::setUp();
40
    }
41
42
    protected function createStatementRepository()
43
    {
44
        return new StatementRepository($this->repository);
45
    }
46
47
    protected function cleanDatabase()
48
    {
49
        foreach ($this->repository->findMappedStatements(array()) as $statement) {
50
            $this->objectManager->remove($statement);
51
        }
52
53
        $this->objectManager->flush();
54
    }
55
56
    /**
57
     * @return ObjectManager
58
     */
59
    abstract protected function createObjectManager();
60
61
    /**
62
     * @return string
63
     */
64
    abstract protected function getStatementClassName();
65
66
    private function createRepository()
67
    {
68
        return $this->objectManager->getRepository($this->getStatementClassName());
69
    }
70
}
71