Completed
Pull Request — master (#8)
by
unknown
02:39
created

ActivityRepositoryTest::createObjectStorageMock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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\Tests\Unit\Repository;
13
14
use PHPUnit\Framework\TestCase;
15
use Xabbuh\XApi\DataFixtures\ActivityFixtures;
16
use Xabbuh\XApi\Model\IRI;
17
use XApi\Repository\Doctrine\Mapping\Object as MappedObject;
18
use XApi\Repository\Doctrine\Repository\ActivityRepository;
19
use XApi\Repository\Doctrine\Storage\ObjectStorage;
20
21
/**
22
 * @author Jérôme Parmentier <[email protected]>
23
 */
24
class ActivityRepositoryTest extends TestCase
25
{
26
    /**
27
     * @var \PHPUnit_Framework_MockObject_MockObject|ObjectStorage
28
     */
29
    private $mappedStatementRepository;
30
31
    /**
32
     * @var ActivityRepository
33
     */
34
    private $activityRepository;
35
36
    protected function setUp()
37
    {
38
        $this->mappedStatementRepository = $this->createObjectStorageMock();
39
        $this->activityRepository = new ActivityRepository($this->mappedStatementRepository);
40
    }
41
42
    public function testFindActivityById()
43
    {
44
        $activityId = IRI::fromString('http://tincanapi.com/conformancetest/activityid');
45
46
        $this
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<XApi\Repository\D...\Storage\ObjectStorage>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            ->mappedStatementRepository
48
            ->expects($this->once())
49
            ->method('findObject')
50
            ->with(array(
51
                'type' => 'activity',
52
                'activityId' => $activityId->getValue(),
53
            ))
54
            ->will($this->returnValue(MappedObject::fromModel(ActivityFixtures::getIdActivity())));
55
56
        $this->activityRepository->findActivityById($activityId);
57
    }
58
59
    /**
60
     * @return \PHPUnit_Framework_MockObject_MockObject|ObjectStorage
61
     */
62
    protected function createObjectStorageMock()
63
    {
64
        return $this
65
            ->getMockBuilder('\XApi\Repository\Doctrine\Storage\ObjectStorage')
66
            ->getMock();
67
    }
68
}
69