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; }
public static function getMultiplePairsExtensions() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/color'), array('model' => 'RGB', 'value' => '#FFFFFF')); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/starting-position'), 1); return new Extensions($extensions); }
public function getModel() { $display = null; if (null !== $this->display) { $display = LanguageMap::create($this->display); } return new VerbModel(IRI::fromString($this->id), $display); }
public function getModel() { $extensions = new \SplObjectStorage(); foreach ($this->extensions as $key => $extension) { $extensions->attach(IRI::fromString($key), $extension); } return new ExtensionsModel($extensions); }
public function getModel() { $description = null; if ($this->hasDescription) { $description = LanguageMap::create($this->description); } return new AttachmentModel(IRI::fromString($this->usageType), $this->contentType, $this->length, $this->sha2, LanguageMap::create($this->display), $description, $this->fileUrl); }
function it_can_filter_by_activity() { $iri = IRI::fromString('http://tincanapi.com/conformancetest/activityid'); $this->byActivity(new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')))->shouldReturn($this); $filter = $this->getFilter(); $filter->shouldHaveCount(1); $filter->shouldHaveKeyWithValue('activity', 'http://tincanapi.com/conformancetest/activityid'); }
/** * 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 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_is_not_equal_to_other_result_if_extensions_are_not_equal() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $this->beConstructedWith(new Score(1), true, true, 'test', 'PT2H', new Extensions($extensions)); $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/subject'), 'Conformance Testing'); $this->equals(new Result(new Score(1), true, true, 'test', 'PT2H', new Extensions($extensions)))->shouldReturn(false); }
function its_equal_to_other_extensions_even_if_extension_names_are_in_different_order() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/color'), array('model' => 'RGB', 'value' => '#FFFFFF')); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/starting-position'), 1); $this->beConstructedWith($extensions); $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/starting-position'), 1); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/color'), array('model' => 'RGB', 'value' => '#FFFFFF')); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $this->equals(new Extensions($extensions))->shouldReturn(true); }
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_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 getAllPropertiesDefinition() { return new Definition(LanguageMap::create(array('en-US' => 'test')), LanguageMap::create(array('en-US' => 'test')), IRI::fromString('http://id.tincanapi.com/activitytype/unit-test'), IRL::fromString('https://github.com/adlnet/xAPI_LRS_Test'), ExtensionsFixtures::getTypicalExtensions()); }
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_equal_with_other_activity_if_ids_are_equal_and_definitions_are_missing() { $this->beConstructedWith(IRI::fromString('http://tincanapi.com/conformancetest/activityid')); $this->equals(new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid')))->shouldReturn(true); }
public static function getFileUrlOnlyAttachment() { return new Attachment(IRI::fromString('http://id.tincanapi.com/attachment/supporting_media'), 'application/octet-stream', 65556, 'd14f1580a2cebb6f8d4a8a2fc0d13c67f970e84f8d15677a93ae95c9080df899', LanguageMap::create(array('en-US' => 'FileUrl Only attachment')), null, IRL::fromString('http://tincanapi.com/conformancetest/attachment/fileUrlOnly')); }
function it_is_not_equal_to_other_context_if_extensions_are_not_equal() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/subject'), 'Conformance Testing'); $context = $this->withExtensions(new Extensions($extensions)); $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $otherContext = new Context(); $otherContext = $otherContext->withExtensions(new Extensions($extensions)); $context->equals($otherContext)->shouldReturn(false); }
function it_is_not_equal_with_other_statement_if_attachments_differ() { $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')); $jsonAttachment = new Attachment(IRI::fromString('http://id.tincanapi.com/attachment/supporting_media'), 'application/json', 60, 'f4135c31e2710764604195dfe4e225884d8108467cc21670803e384b80df88ee', LanguageMap::create(array('en-US' => 'JSON attachment')), null, IRL::fromString('http://tincanapi.com/conformancetest/attachment/fileUrlOnly')); $statement = $this->withAttachments(array($textAttachment)); $statement->equals($statement->withAttachments(array($jsonAttachment)))->shouldReturn(false); }
public static function getForQueryVerb() { return new Verb(IRI::fromString('http://tincanapi.com/conformancetest/verbid/forQuery'), LanguageMap::create(array('en-US' => 'for query'))); }
public function testGetStatementsWithVerbInStatementsFilter() { $filter = new StatementsFilter(); $verb = new Verb(IRI::fromString('http://adlnet.gov/expapi/verbs/attended')); $filter->byVerb($verb); $statementResult = $this->createStatementResult(); $this->validateRetrieveApiCall('get', 'statements', array('verb' => 'http://adlnet.gov/expapi/verbs/attended'), 200, 'StatementResult', $statementResult); $this->assertEquals($statementResult, $this->client->getStatements($filter)); }
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'))); }
function it_is_equal_to_other_definition_if_properties_are_equal() { $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $this->beConstructedWith(LanguageMap::create(array('en-US' => 'test')), LanguageMap::create(array('en-US' => 'test')), IRI::fromString('http://id.tincanapi.com/activitytype/unit-test'), IRL::fromString('https://github.com/adlnet/xAPI_LRS_Test'), new Extensions($extensions)); $extensions = new \SplObjectStorage(); $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing'); $definition = $this->createEmptyDefinition(); $definition = $definition->withName(LanguageMap::create(array('en-US' => 'test'))); $definition = $definition->withDescription(LanguageMap::create(array('en-US' => 'test'))); $definition = $definition->withType(IRI::fromString('http://id.tincanapi.com/activitytype/unit-test')); $definition = $definition->withMoreInfo(IRL::fromString('https://github.com/adlnet/xAPI_LRS_Test')); $definition = $definition->withExtensions(new Extensions($extensions)); $this->equals($definition)->shouldReturn(true); }
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 getObjectsToValidate() { return array(array(ActivityFixtures::getTypicalActivity(), 0), array(new Activity(IRI::fromString('')), 1)); }
private function createAgentProfile() { $agent = new Agent(InverseFunctionalIdentifier::withMbox(IRI::fromString('mailto:christian@example.com'))); $profile = new AgentProfile('profile-id', $agent); return $profile; }
/** * 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); }
function it_is_equal_to_other_attachment_if_all_properties_are_equal() { $this->beConstructedWith(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')); $attachment = 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')); $this->equals($attachment)->shouldReturn(true); }
/** * 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); }
public static function getForQueryActivity() { return new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid/forQuery'), DefinitionFixtures::getForQueryDefinition()); }
function let() { $this->beConstructedWith(new ActivityProfile('id', new Activity(IRI::fromString('http://tincanapi.com/conformancetest/activityid'))), new DocumentData(array('x' => 'foo', 'y' => 'bar'))); }