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\Api\Test\Functional; |
13
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\Activity; |
15
|
|
|
use Xabbuh\XApi\Model\IRI; |
16
|
|
|
use XApi\Repository\Api\ActivityRepositoryInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author Jérôme Parmentier <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
abstract class ActivityRepositoryTest extends \PHPUnit_Framework_TestCase |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var ActivityRepositoryInterface |
25
|
|
|
*/ |
26
|
|
|
private $activityRepository; |
27
|
|
|
|
28
|
|
|
protected function setUp() |
29
|
|
|
{ |
30
|
|
|
$this->activityRepository = $this->createActivityRepository(); |
31
|
|
|
$this->cleanDatabase(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function tearDown() |
35
|
|
|
{ |
36
|
|
|
$this->cleanDatabase(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @expectedException \Xabbuh\XApi\Common\Exception\NotFoundException |
41
|
|
|
*/ |
42
|
|
|
public function testFetchingNonExistingActivityThrowsException() |
43
|
|
|
{ |
44
|
|
|
$this->activityRepository->findActivityById(IRI::fromString('not-existing')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @dataProvider getStatementsWithId |
49
|
|
|
*/ |
50
|
|
|
public function testActivitiesCanBeRetrievedById(Activity $activity) |
51
|
|
|
{ |
52
|
|
|
$fetchedActivity = $this->activityRepository->findActivityById($activity->getId()); |
53
|
|
|
|
54
|
|
|
$this->assertTrue($activity->equals($fetchedActivity)); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getActivitiesWithId() |
58
|
|
|
{ |
59
|
|
|
$fixtures = array(); |
60
|
|
|
|
61
|
|
|
foreach (get_class_methods('Xabbuh\XApi\DataFixtures\ActivityFixtures') as $method) { |
62
|
|
|
$activity = call_user_func(array('Xabbuh\XApi\DataFixtures\ActivityFixtures', $method)); |
63
|
|
|
|
64
|
|
|
if ($activity instanceof Activity) { |
65
|
|
|
$fixtures[$method] = array($activity); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $fixtures; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
abstract protected function createActivityRepository(); |
73
|
|
|
|
74
|
|
|
abstract protected function cleanDatabase(); |
75
|
|
|
} |
76
|
|
|
|