Completed
Pull Request — master (#8)
by
unknown
04:37
created

ActivityRepositoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 52
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A createActivityRepository() 0 4 1
A cleanDatabase() 0 11 1
createObjectManager() 0 1 ?
getActivityClassName() 0 1 ?
A createStorage() 0 4 1
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 Xabbuh\XApi\Model\IRI;
16
use XApi\Repository\Api\Test\Functional\ActivityRepositoryTest as BaseActivityRepositoryTest;
17
use XApi\Repository\Doctrine\Repository\ActivityRepository;
18
use XApi\Repository\Doctrine\Storage\ObjectStorage;
19
use XApi\Repository\Doctrine\Test\ActivityRepository as FreshActivityRepository;
20
21
/**
22
 * @author Jérôme Parmentier <[email protected]>
23
 */
24
abstract class ActivityRepositoryTest extends BaseActivityRepositoryTest
25
{
26
    /**
27
     * @var ObjectManager
28
     */
29
    protected $objectManager;
30
31
    /**
32
     * @var ObjectStorage
33
     */
34
    protected $storage;
35
36
    protected function setUp()
37
    {
38
        $this->objectManager = $this->createObjectManager();
39
        $this->storage = $this->createStorage();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createStorage() of type object<Doctrine\Common\P...tence\ObjectRepository> is incompatible with the declared type object<XApi\Repository\D...\Storage\ObjectStorage> of property $storage.

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...
40
41
        parent::setUp();
42
    }
43
44
    protected function createActivityRepository()
45
    {
46
        return new FreshActivityRepository(new ActivityRepository($this->storage), $this->objectManager);
47
    }
48
49
    protected function cleanDatabase()
50
    {
51
        $this->objectManager->remove($this->storage->findObject(
52
            array(
53
                'type' => 'activity',
54
                'activityId' => IRI::fromString('http://tincanapi.com/conformancetest/activityid')->getValue(),
55
            )
56
        ));
57
58
        $this->objectManager->flush();
59
    }
60
61
    /**
62
     * @return ObjectManager
63
     */
64
    abstract protected function createObjectManager();
65
66
    /**
67
     * @return string
68
     */
69
    abstract protected function getActivityClassName();
70
71
    private function createStorage()
72
    {
73
        return $this->objectManager->getRepository($this->getActivityClassName());
74
    }
75
}
76