Skip to content

Commit 97e31e8

Browse files
committed
pass only IRI string values to the HTTP layer
1 parent 2eeb7e1 commit 97e31e8

8 files changed

+22
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php": ">=5.3.0",
1616
"guzzle/guzzle": "~3.7",
1717
"php-xapi/exception": "^0.1.0",
18-
"php-xapi/model": "^0.5.0",
18+
"php-xapi/model": "^0.5.1",
1919
"php-xapi/serializer": "^0.3.0"
2020
},
2121
"require-dev": {

src/Api/ActivityProfileApiClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function createOrReplaceDocument(ActivityProfileDocument $document)
4444
public function deleteDocument(ActivityProfile $profile)
4545
{
4646
$this->doDeleteDocument('activities/profile', array(
47-
'activityId' => $profile->getActivity()->getId(),
47+
'activityId' => $profile->getActivity()->getId()->getValue(),
4848
'profileId' => $profile->getProfileId(),
4949
));
5050
}
@@ -56,7 +56,7 @@ public function getDocument(ActivityProfile $profile)
5656
{
5757
/** @var \Xabbuh\XApi\Model\DocumentData $documentData */
5858
$documentData = $this->doGetDocument('activities/profile', array(
59-
'activityId' => $profile->getActivity()->getId(),
59+
'activityId' => $profile->getActivity()->getId()->getValue(),
6060
'profileId' => $profile->getProfileId(),
6161
));
6262

@@ -76,7 +76,7 @@ private function doStoreActivityProfileDocument($method, ActivityProfileDocument
7676
$method,
7777
'activities/profile',
7878
array(
79-
'activityId' => $profile->getActivity()->getId(),
79+
'activityId' => $profile->getActivity()->getId()->getValue(),
8080
'profileId' => $profile->getProfileId(),
8181
),
8282
$document

src/Api/StateApiClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createOrReplaceDocument(StateDocument $document)
6868
public function deleteDocument(State $state)
6969
{
7070
$this->doDeleteDocument('activities/state', array(
71-
'activityId' => $state->getActivity()->getId(),
71+
'activityId' => $state->getActivity()->getId()->getValue(),
7272
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
7373
'stateId' => $state->getStateId(),
7474
));
@@ -81,7 +81,7 @@ public function getDocument(State $state)
8181
{
8282
/** @var \Xabbuh\XApi\Model\DocumentData $documentData */
8383
$documentData = $this->doGetDocument('activities/state', array(
84-
'activityId' => $state->getActivity()->getId(),
84+
'activityId' => $state->getActivity()->getId()->getValue(),
8585
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
8686
'stateId' => $state->getStateId(),
8787
));
@@ -102,7 +102,7 @@ private function doStoreStateDocument($method, StateDocument $document)
102102
$method,
103103
'activities/state',
104104
array(
105-
'activityId' => $state->getActivity()->getId(),
105+
'activityId' => $state->getActivity()->getId()->getValue(),
106106
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
107107
'stateId' => $state->getStateId(),
108108
),

src/Api/StatementsApiClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Xabbuh\XApi\Client\Api;
1313

1414
use Xabbuh\XApi\Client\Request\HandlerInterface;
15+
use Xabbuh\XApi\Model\IRL;
1516
use Xabbuh\XApi\Model\StatementId;
1617
use Xabbuh\XApi\Serializer\ActorSerializerInterface;
1718
use Xabbuh\XApi\Serializer\StatementResultSerializerInterface;
@@ -147,7 +148,7 @@ public function getStatements(StatementsFilter $filter = null)
147148
*/
148149
public function getNextStatements(StatementResult $statementResult)
149150
{
150-
return $this->doGetStatements($statementResult->getMoreUrlPath());
151+
return $this->doGetStatements($statementResult->getMoreUrlPath()->getValue());
151152
}
152153

153154
/**

tests/Api/ActivityProfileApiClientTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Xabbuh\XApi\DataFixtures\DocumentFixtures;
1616
use Xabbuh\XApi\Model\Activity;
1717
use Xabbuh\XApi\Model\ActivityProfile;
18+
use Xabbuh\XApi\Model\IRI;
1819
use Xabbuh\XApi\Serializer\DocumentDataSerializer;
1920

2021
/**
@@ -112,7 +113,7 @@ public function testGetDocument()
112113

113114
private function createActivityProfile()
114115
{
115-
$activity = new Activity('activity-id');
116+
$activity = new Activity(IRI::fromString('activity-id'));
116117
$activityProfile = new ActivityProfile('profile-id', $activity);
117118

118119
return $activityProfile;

tests/Api/AgentProfileApiClientTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Xabbuh\XApi\Model\Agent;
1717
use Xabbuh\XApi\Model\AgentProfile;
1818
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
19+
use Xabbuh\XApi\Model\IRI;
1920
use Xabbuh\XApi\Serializer\ActorSerializer;
2021
use Xabbuh\XApi\Serializer\DocumentDataSerializer;
2122

@@ -126,7 +127,7 @@ public function testGetDocument()
126127

127128
private function createAgentProfile()
128129
{
129-
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
130+
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
130131
$profile = new AgentProfile('profile-id', $agent);
131132

132133
return $profile;

tests/Api/StateApiClientTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Xabbuh\XApi\Model\Activity;
1717
use Xabbuh\XApi\Model\Agent;
1818
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
19+
use Xabbuh\XApi\Model\IRI;
1920
use Xabbuh\XApi\Model\State;
2021
use Xabbuh\XApi\Serializer\ActorSerializer;
2122
use Xabbuh\XApi\Serializer\DocumentDataSerializer;
@@ -127,8 +128,8 @@ public function testGetDocument()
127128

128129
private function createState()
129130
{
130-
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
131-
$activity = new Activity('activity-id');
131+
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
132+
$activity = new Activity(IRI::fromString('activity-id'));
132133
$state = new State($activity, $agent, 'state-id');
133134

134135
return $state;

tests/Api/StatementsApiClientTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Xabbuh\XApi\DataFixtures\StatementFixtures;
1616
use Xabbuh\XApi\Model\Agent;
1717
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
18+
use Xabbuh\XApi\Model\IRI;
19+
use Xabbuh\XApi\Model\IRL;
1820
use Xabbuh\XApi\Model\Statement;
1921
use Xabbuh\XApi\Model\StatementId;
2022
use Xabbuh\XApi\Model\StatementReference;
@@ -161,7 +163,7 @@ public function testVoidStatement()
161163
{
162164
$voidedStatementId = '12345678-1234-5678-1234-567812345679';
163165
$voidingStatementId = '12345678-1234-5678-1234-567812345678';
164-
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
166+
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
165167
$statementReference = new StatementReference(StatementId::fromString($voidedStatementId));
166168
$voidingStatement = new Statement(null, $agent, Verb::createVoidVerb(), $statementReference);
167169
$voidedStatement = $this->createStatement($voidedStatementId);
@@ -288,7 +290,7 @@ public function testGetStatementsWithAgentInStatementsFilter()
288290
{
289291
// {"mbox":"mailto:[email protected]","objectType":"Agent"}
290292
$filter = new StatementsFilter();
291-
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:[email protected]'));
293+
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:[email protected]')));
292294
$filter->byActor($agent);
293295
$statementResult = $this->createStatementResult();
294296
$agentJson = '{"mbox":"mailto:[email protected]","objectType":"Agent"}';
@@ -312,7 +314,7 @@ public function testGetStatementsWithAgentInStatementsFilter()
312314
public function testGetStatementsWithVerbInStatementsFilter()
313315
{
314316
$filter = new StatementsFilter();
315-
$verb = new Verb('http://adlnet.gov/expapi/verbs/attended');
317+
$verb = new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/attended'));
316318
$filter->byVerb($verb);
317319
$statementResult = $this->createStatementResult();
318320
$this->validateRetrieveApiCall(
@@ -330,7 +332,7 @@ public function testGetStatementsWithVerbInStatementsFilter()
330332
public function testGetNextStatements()
331333
{
332334
$moreUrl = '/xapi/statements/more/b381d8eca64a61a42c7b9b4ecc2fabb6';
333-
$previousStatementResult = new StatementResult(array(), $moreUrl);
335+
$previousStatementResult = new StatementResult(array(), IRL::fromString($moreUrl));
334336
$this->validateRetrieveApiCall(
335337
'get',
336338
$moreUrl,

0 commit comments

Comments
 (0)