Skip to content

Commit

Permalink
pass only IRI string values to the HTTP layer
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Sep 26, 2016
1 parent 2eeb7e1 commit 97e31e8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"php": ">=5.3.0",
"guzzle/guzzle": "~3.7",
"php-xapi/exception": "^0.1.0",
"php-xapi/model": "^0.5.0",
"php-xapi/model": "^0.5.1",
"php-xapi/serializer": "^0.3.0"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ActivityProfileApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function createOrReplaceDocument(ActivityProfileDocument $document)
public function deleteDocument(ActivityProfile $profile)
{
$this->doDeleteDocument('activities/profile', array(
'activityId' => $profile->getActivity()->getId(),
'activityId' => $profile->getActivity()->getId()->getValue(),
'profileId' => $profile->getProfileId(),
));
}
Expand All @@ -56,7 +56,7 @@ public function getDocument(ActivityProfile $profile)
{
/** @var \Xabbuh\XApi\Model\DocumentData $documentData */
$documentData = $this->doGetDocument('activities/profile', array(
'activityId' => $profile->getActivity()->getId(),
'activityId' => $profile->getActivity()->getId()->getValue(),
'profileId' => $profile->getProfileId(),
));

Expand All @@ -76,7 +76,7 @@ private function doStoreActivityProfileDocument($method, ActivityProfileDocument
$method,
'activities/profile',
array(
'activityId' => $profile->getActivity()->getId(),
'activityId' => $profile->getActivity()->getId()->getValue(),
'profileId' => $profile->getProfileId(),
),
$document
Expand Down
6 changes: 3 additions & 3 deletions src/Api/StateApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function createOrReplaceDocument(StateDocument $document)
public function deleteDocument(State $state)
{
$this->doDeleteDocument('activities/state', array(
'activityId' => $state->getActivity()->getId(),
'activityId' => $state->getActivity()->getId()->getValue(),
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
'stateId' => $state->getStateId(),
));
Expand All @@ -81,7 +81,7 @@ public function getDocument(State $state)
{
/** @var \Xabbuh\XApi\Model\DocumentData $documentData */
$documentData = $this->doGetDocument('activities/state', array(
'activityId' => $state->getActivity()->getId(),
'activityId' => $state->getActivity()->getId()->getValue(),
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
'stateId' => $state->getStateId(),
));
Expand All @@ -102,7 +102,7 @@ private function doStoreStateDocument($method, StateDocument $document)
$method,
'activities/state',
array(
'activityId' => $state->getActivity()->getId(),
'activityId' => $state->getActivity()->getId()->getValue(),
'agent' => $this->actorSerializer->serializeActor($state->getActor()),
'stateId' => $state->getStateId(),
),
Expand Down
3 changes: 2 additions & 1 deletion src/Api/StatementsApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Xabbuh\XApi\Client\Api;

use Xabbuh\XApi\Client\Request\HandlerInterface;
use Xabbuh\XApi\Model\IRL;
use Xabbuh\XApi\Model\StatementId;
use Xabbuh\XApi\Serializer\ActorSerializerInterface;
use Xabbuh\XApi\Serializer\StatementResultSerializerInterface;
Expand Down Expand Up @@ -147,7 +148,7 @@ public function getStatements(StatementsFilter $filter = null)
*/
public function getNextStatements(StatementResult $statementResult)
{
return $this->doGetStatements($statementResult->getMoreUrlPath());
return $this->doGetStatements($statementResult->getMoreUrlPath()->getValue());
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Api/ActivityProfileApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Xabbuh\XApi\DataFixtures\DocumentFixtures;
use Xabbuh\XApi\Model\Activity;
use Xabbuh\XApi\Model\ActivityProfile;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Serializer\DocumentDataSerializer;

/**
Expand Down Expand Up @@ -112,7 +113,7 @@ public function testGetDocument()

private function createActivityProfile()
{
$activity = new Activity('activity-id');
$activity = new Activity(IRI::fromString('activity-id'));
$activityProfile = new ActivityProfile('profile-id', $activity);

return $activityProfile;
Expand Down
3 changes: 2 additions & 1 deletion tests/Api/AgentProfileApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Xabbuh\XApi\Model\Agent;
use Xabbuh\XApi\Model\AgentProfile;
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Serializer\ActorSerializer;
use Xabbuh\XApi\Serializer\DocumentDataSerializer;

Expand Down Expand Up @@ -126,7 +127,7 @@ public function testGetDocument()

private function createAgentProfile()
{
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:christian@example.com'));
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:christian@example.com')));
$profile = new AgentProfile('profile-id', $agent);

return $profile;
Expand Down
5 changes: 3 additions & 2 deletions tests/Api/StateApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Xabbuh\XApi\Model\Activity;
use Xabbuh\XApi\Model\Agent;
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Model\State;
use Xabbuh\XApi\Serializer\ActorSerializer;
use Xabbuh\XApi\Serializer\DocumentDataSerializer;
Expand Down Expand Up @@ -127,8 +128,8 @@ public function testGetDocument()

private function createState()
{
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:alice@example.com'));
$activity = new Activity('activity-id');
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:alice@example.com')));
$activity = new Activity(IRI::fromString('activity-id'));
$state = new State($activity, $agent, 'state-id');

return $state;
Expand Down
10 changes: 6 additions & 4 deletions tests/Api/StatementsApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Xabbuh\XApi\DataFixtures\StatementFixtures;
use Xabbuh\XApi\Model\Agent;
use Xabbuh\XApi\Model\InverseFunctionalIdentifier;
use Xabbuh\XApi\Model\IRI;
use Xabbuh\XApi\Model\IRL;
use Xabbuh\XApi\Model\Statement;
use Xabbuh\XApi\Model\StatementId;
use Xabbuh\XApi\Model\StatementReference;
Expand Down Expand Up @@ -161,7 +163,7 @@ public function testVoidStatement()
{
$voidedStatementId = '12345678-1234-5678-1234-567812345679';
$voidingStatementId = '12345678-1234-5678-1234-567812345678';
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:john.doe@example.com'));
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:john.doe@example.com')));
$statementReference = new StatementReference(StatementId::fromString($voidedStatementId));
$voidingStatement = new Statement(null, $agent, Verb::createVoidVerb(), $statementReference);
$voidedStatement = $this->createStatement($voidedStatementId);
Expand Down Expand Up @@ -288,7 +290,7 @@ public function testGetStatementsWithAgentInStatementsFilter()
{
// {"mbox":"mailto:alice@example.com","objectType":"Agent"}
$filter = new StatementsFilter();
$agent = new Agent(InverseFunctionalIdentifier::withMbox('mailto:alice@example.com'));
$agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:alice@example.com')));
$filter->byActor($agent);
$statementResult = $this->createStatementResult();
$agentJson = '{"mbox":"mailto:alice@example.com","objectType":"Agent"}';
Expand All @@ -312,7 +314,7 @@ public function testGetStatementsWithAgentInStatementsFilter()
public function testGetStatementsWithVerbInStatementsFilter()
{
$filter = new StatementsFilter();
$verb = new Verb('http://adlnet.gov/expapi/verbs/attended');
$verb = new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/attended'));
$filter->byVerb($verb);
$statementResult = $this->createStatementResult();
$this->validateRetrieveApiCall(
Expand All @@ -330,7 +332,7 @@ public function testGetStatementsWithVerbInStatementsFilter()
public function testGetNextStatements()
{
$moreUrl = '/xapi/statements/more/b381d8eca64a61a42c7b9b4ecc2fabb6';
$previousStatementResult = new StatementResult(array(), $moreUrl);
$previousStatementResult = new StatementResult(array(), IRL::fromString($moreUrl));
$this->validateRetrieveApiCall(
'get',
$moreUrl,
Expand Down

0 comments on commit 97e31e8

Please sign in to comment.