|
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 Xabbuh\XApi\Client\Tests\Api; |
|
13
|
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Client\Api\ActivityProfileApiClient; |
|
15
|
|
|
use Xabbuh\XApi\DataFixtures\DocumentFixtures; |
|
16
|
|
|
use Xabbuh\XApi\Model\Activity; |
|
17
|
|
|
use Xabbuh\XApi\Model\ActivityProfile; |
|
18
|
|
|
use Xabbuh\XApi\Model\IRI; |
|
19
|
|
|
use Xabbuh\XApi\Serializer\DocumentDataSerializer; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @author Christian Flothmann <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class ActivityProfileApiClientTest extends ApiClientTest |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var ActivityProfileApiClient |
|
28
|
|
|
*/ |
|
29
|
|
|
private $client; |
|
30
|
|
|
|
|
31
|
|
|
protected function setUp() |
|
32
|
|
|
{ |
|
33
|
|
|
parent::setUp(); |
|
34
|
|
|
$this->client = new ActivityProfileApiClient( |
|
35
|
|
|
$this->requestHandler, |
|
36
|
|
|
'1.0.1', |
|
37
|
|
|
new DocumentDataSerializer($this->serializer) |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testCreateOrUpdateDocument() |
|
42
|
|
|
{ |
|
43
|
|
|
$document = DocumentFixtures::getActivityProfileDocument(); |
|
44
|
|
|
|
|
45
|
|
|
$this->validateStoreApiCall( |
|
46
|
|
|
'post', |
|
47
|
|
|
'activities/profile', |
|
48
|
|
|
array( |
|
49
|
|
|
'activityId' => 'activity-id', |
|
50
|
|
|
'profileId' => 'profile-id', |
|
51
|
|
|
), |
|
52
|
|
|
204, |
|
53
|
|
|
'', |
|
54
|
|
|
$document->getData() |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
$this->client->createOrUpdateDocument($document); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testCreateOrReplaceDocument() |
|
61
|
|
|
{ |
|
62
|
|
|
$document = DocumentFixtures::getActivityProfileDocument(); |
|
63
|
|
|
|
|
64
|
|
|
$this->validateStoreApiCall( |
|
65
|
|
|
'put', |
|
66
|
|
|
'activities/profile', |
|
67
|
|
|
array( |
|
68
|
|
|
'activityId' => 'activity-id', |
|
69
|
|
|
'profileId' => 'profile-id', |
|
70
|
|
|
), |
|
71
|
|
|
204, |
|
72
|
|
|
'', |
|
73
|
|
|
$document->getData() |
|
74
|
|
|
); |
|
75
|
|
|
|
|
76
|
|
|
$this->client->createOrReplaceDocument($document); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function testDeleteDocument() |
|
80
|
|
|
{ |
|
81
|
|
|
$activityProfile = $this->createActivityProfile(); |
|
82
|
|
|
|
|
83
|
|
|
$this->validateDeleteDocumentCall('activities/profile', array( |
|
84
|
|
|
'activityId' => 'activity-id', |
|
85
|
|
|
'profileId' => 'profile-id', |
|
86
|
|
|
)); |
|
87
|
|
|
|
|
88
|
|
|
$this->client->deleteDocument($activityProfile); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function testGetDocument() |
|
92
|
|
|
{ |
|
93
|
|
|
$document = DocumentFixtures::getActivityProfileDocument(); |
|
94
|
|
|
$activityProfile = $document->getActivityProfile(); |
|
95
|
|
|
|
|
96
|
|
|
$this->validateRetrieveApiCall( |
|
97
|
|
|
'get', |
|
98
|
|
|
'activities/profile', |
|
99
|
|
|
array( |
|
100
|
|
|
'activityId' => 'activity-id', |
|
101
|
|
|
'profileId' => 'profile-id', |
|
102
|
|
|
), |
|
103
|
|
|
200, |
|
104
|
|
|
'DocumentData', |
|
105
|
|
|
$document->getData() |
|
106
|
|
|
); |
|
107
|
|
|
|
|
108
|
|
|
$document = $this->client->getDocument($activityProfile); |
|
109
|
|
|
|
|
110
|
|
|
$this->assertInstanceOf('Xabbuh\XApi\Model\ActivityProfileDocument', $document); |
|
111
|
|
|
$this->assertEquals($activityProfile, $document->getActivityProfile()); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
private function createActivityProfile() |
|
115
|
|
|
{ |
|
116
|
|
|
$activity = new Activity(IRI::fromString('activity-id')); |
|
117
|
|
|
$activityProfile = new ActivityProfile('profile-id', $activity); |
|
118
|
|
|
|
|
119
|
|
|
return $activityProfile; |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|