1 | <?php |
||
22 | abstract class ActivityRepositoryTest extends TestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var ActivityRepositoryInterface |
||
26 | */ |
||
27 | private $activityRepository; |
||
28 | |||
29 | protected function setUp() |
||
30 | { |
||
31 | $this->activityRepository = $this->createActivityRepository(); |
||
32 | $this->cleanDatabase(); |
||
33 | } |
||
34 | |||
35 | protected function tearDown() |
||
36 | { |
||
37 | $this->cleanDatabase(); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @expectedException \Xabbuh\XApi\Common\Exception\NotFoundException |
||
42 | */ |
||
43 | public function testFetchingNonExistingActivityThrowsException() |
||
44 | { |
||
45 | $this->activityRepository->findActivityById(IRI::fromString('not-existing')); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @dataProvider getStatementsWithId |
||
50 | */ |
||
51 | public function testActivitiesCanBeRetrievedById(Activity $activity) |
||
52 | { |
||
53 | $fetchedActivity = $this->activityRepository->findActivityById($activity->getId()); |
||
54 | |||
55 | $this->assertTrue($activity->equals($fetchedActivity)); |
||
56 | } |
||
57 | |||
58 | public function getActivitiesWithId() |
||
59 | { |
||
60 | $fixtures = array(); |
||
61 | |||
62 | foreach (get_class_methods('Xabbuh\XApi\DataFixtures\ActivityFixtures') as $method) { |
||
63 | $activity = call_user_func(array('Xabbuh\XApi\DataFixtures\ActivityFixtures', $method)); |
||
64 | |||
65 | if ($activity instanceof Activity) { |
||
66 | $fixtures[$method] = array($activity); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | return $fixtures; |
||
71 | } |
||
72 | |||
73 | abstract protected function createActivityRepository(); |
||
74 | |||
75 | abstract protected function cleanDatabase(); |
||
76 | } |
||
77 |