private function createState() { $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; }
/** * Loads a statement result. * * @param IRL $urlPath An optional URL path refering to more results * * @return StatementResult */ public static function getStatementResult(IRL $urlPath = null) { $statement1 = StatementFixtures::getMinimalStatement(); $verb = new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/deleted'), LanguageMap::create(array('en-US' => 'deleted'))); $statement2 = new Statement(StatementId::fromString('12345678-1234-5678-8234-567812345679'), new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:bob@example.com'))), $verb, $statement1->getObject()); $statementResult = new StatementResult(array($statement1, $statement2), $urlPath); return $statementResult; }
function it_can_filter_by_actor() { $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com'))); $this->byActor($actor)->shouldReturn($this); $filter = $this->getFilter(); $filter->shouldHaveCount(1); $filter->shouldHaveKeyWithValue('agent', $actor); }
function its_properties_can_be_read() { $iri = InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com')); $members = array(new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com')))); $this->beConstructedWith($iri, 'test', $members); $this->getInverseFunctionalIdentifier()->shouldReturn($iri); $this->getName()->shouldReturn('test'); $this->getMembers()->shouldReturn($members); }
function it_ignores_array_keys_in_attachment_lists() { $textAttachment = new Attachment(IRI::fromString('http://id.tincanapi.com/attachment/supporting_media'), 'text/plain', 18, 'bd1a58265d96a3d1981710dab8b1e1ed04a8d7557ea53ab0cf7b44c04fd01545', LanguageMap::create(array('en-US' => 'Text attachment')), LanguageMap::create(array('en-US' => 'Text attachment description')), IRL::fromString('http://tincanapi.com/conformancetest/attachment/fileUrlOnly')); $attachments = array(1 => $textAttachment); $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com'))); $verb = new Verb(IRI::fromString('http://tincanapi.com/conformancetest/verbid'), LanguageMap::create(array('en-US' => 'test'))); $object = new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')); $this->beConstructedWith($actor, $verb, $object, null, null, null, $attachments); $this->getAttachments()->shouldBeArray(); $this->getAttachments()->shouldHaveKeyWithValue(0, $textAttachment); $statement = $this->withAttachments($attachments); $statement->getAttachments()->shouldBeArray(); $statement->getAttachments()->shouldHaveKeyWithValue(0, $textAttachment); }
public static function getAllPropertiesAndTwoTypicalAgentMembersGroup() { return new Group(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest-group@tincanapi.com')), 'test group', array(self::getTypicalAgent(), self::getTypicalAgent())); }
function it_is_not_equal_to_other_context_if_teams_are_not_equal() { $context = $this->withTeam(new Group()); $otherContext = new Context(); $otherContext = $otherContext->withTeam(new Group(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest-group@tincanapi.com')))); $context->equals($otherContext)->shouldReturn(false); }
function let() { $activity = new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')); $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com'))); $this->beConstructedWith(new State($activity, $actor, 'state-id'), new DocumentData(array('x' => 'foo', 'y' => 'bar'))); }
private function configureAllProperties() { $id = StatementId::fromString('39e24cc4-69af-4b01-a824-1fdc6ea8a3af'); $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com'))); $verb = new Verb(IRI::fromString('http://tincanapi.com/conformancetest/verbid')); $object = new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')); $result = new Result(); $context = new Context(); $created = new \DateTime('2014-07-23T12:34:02-05:00'); $stored = new \DateTime('2014-07-24T12:34:02-05:00'); $authority = new Agent(InverseFunctionalIdentifier::withOpenId('http://openid.tincanapi.com')); $this->withId($id); $this->withActor($actor); $this->withVerb($verb); $this->withObject($object); $this->withResult($result); $this->withContext($context); $this->withCreated($created); $this->withStored($stored); $this->withAuthority($authority); }
/** * Loads a statement including a sub statement. * * @param string $id The id of the new Statement * * @return Statement */ public static function getStatementWithSubStatement($id = self::DEFAULT_STATEMENT_ID) { if (null === $id) { $id = UuidFixtures::getUniqueUuid(); } $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:test@example.com'))); $verb = new Verb(IRI::fromString('http://example.com/visited'), LanguageMap::create(array('en-US' => 'will visit'))); $definition = new Definition(LanguageMap::create(array('en-US' => 'Some Awesome Website')), LanguageMap::create(array('en-US' => 'The visited website')), IRI::fromString('http://example.com/definition-type')); $activity = new Activity(IRI::fromString('http://example.com/website'), $definition); $subStatement = new SubStatement($actor, $verb, $activity); $actor = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:test@example.com'))); $verb = new Verb(IRI::fromString('http://example.com/planned'), LanguageMap::create(array('en-US' => 'planned'))); return new Statement(StatementId::fromString($id), $actor, $verb, $subStatement); }
/** * Loads a state document. * * @param DocumentData $documentData The document data, by default, a some * default data will be used * * @return StateDocument */ public static function getStateDocument(DocumentData $documentData = null) { if (null === $documentData) { $documentData = static::getDocumentData(); } $agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:alice@example.com'))); $activity = new Activity(IRI::fromString('activity-id')); return new StateDocument(new State($activity, $agent, 'state-id'), $documentData); }
public function testGetStatementsWithAgentInStatementsFilter() { // {"mbox":"mailto:alice@example.com","objectType":"Agent"} $filter = new StatementsFilter(); $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"}'; $this->serializer->expects($this->once())->method('serialize')->with($agent, 'json')->willReturn($agentJson); $this->validateRetrieveApiCall('get', 'statements', array('agent' => $agentJson), 200, 'StatementResult', $statementResult); $this->assertEquals($statementResult, $this->client->getStatements($filter)); }
function it_is_equal_when_accounts_are_equal() { $this->beConstructedThrough('withAccount', array(new Account('test', IRL::fromString('https://tincanapi.com')))); $this->equals(InverseFunctionalIdentifier::withAccount(new Account('test', IRL::fromString('https://tincanapi.com'))))->shouldReturn(true); }
private function createAgentProfile() { $agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:christian@example.com'))); $profile = new AgentProfile('profile-id', $agent); return $profile; }
function let() { $this->beConstructedWith(new AgentProfile('id', new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com')))), new DocumentData(array('x' => 'foo', 'y' => 'bar'))); }
public function getModel() { $inverseFunctionalIdentifier = null; if (null !== $this->mbox) { $inverseFunctionalIdentifier = InverseFunctionalIdentifier::withMbox(IRI::fromString($this->mbox)); } elseif (null !== $this->mboxSha1Sum) { $inverseFunctionalIdentifier = InverseFunctionalIdentifier::withMboxSha1Sum($this->mboxSha1Sum); } elseif (null !== $this->openId) { $inverseFunctionalIdentifier = InverseFunctionalIdentifier::withOpenId($this->openId); } elseif (null !== $this->accountName && null !== $this->accountHomePage) { $inverseFunctionalIdentifier = InverseFunctionalIdentifier::withAccount(new Account($this->accountName, IRL::fromString($this->accountHomePage))); } if ('group' === $this->type) { $members = array(); foreach ($this->members as $agent) { $members[] = $agent->getModel(); } return new Group($inverseFunctionalIdentifier, $this->name, $members); } else { return new Agent($inverseFunctionalIdentifier, $this->name); } }
function it_is_not_equal_to_an_activity() { $this->beConstructedWith(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:conformancetest@tincanapi.com'))); $this->equals(new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')))->shouldReturn(false); }