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