public function testAttachmentsString() { $text_content = "Content created at: " . Util::getTimestamp(); $statement = new Statement(['actor' => ['mbox' => COMMON_MBOX], 'verb' => ['id' => COMMON_VERB_ID], 'object' => new Activity(['id' => COMMON_ACTIVITY_ID . '/StatementVariationsTest/AttachmentsString']), 'attachments' => [['usageType' => 'http://id.tincanapi.com/attachment/supporting_media', 'display' => ['en-US' => 'StatementVariantsTest::testAttachmentsString'], 'contentType' => 'text/plain; charset=ascii', 'content' => $text_content]]]); foreach (self::$lrss as $lrs) { $response = $lrs->saveStatement($statement); $this->assertInstanceOf('TinCan\\LRSResponse', $response); $this->assertTrue($response->success, "successful request"); } }
public function testGetTimestamp() { $result = Util::getTimestamp(); // // this isn't intended to match all ISO8601 just *our* format of it, so it should // catch regressions, at least more than will be accepted by an LRS which is really // ultimately what we want in our tests // $this->assertRegExp('/\\d\\d\\d\\d-[01]\\d-[0123]\\dT[012]\\d:[012345]\\d:[012345]\\d\\.\\d\\d\\d[-+]\\d\\d:\\d\\d/', $result); }
public function testSaveStatementsWithAttachments() { $lrs = new RemoteLRS(self::$endpoint, self::$version, self::$username, self::$password); $attachment1 = ['usageType' => 'http://id.tincanapi.com/attachment/supporting_media', 'display' => ['en-US' => 'RemoteLRSTest::testSaveStatements'], 'contentType' => 'text/plain; charset=ascii', 'content' => 'Attachment 1 content created at: ' . Util::getTimestamp()]; $attachment2 = ['usageType' => 'http://id.tincanapi.com/attachment/supporting_media', 'display' => ['en-US' => 'RemoteLRSTest::testSaveStatements'], 'contentType' => 'text/plain; charset=ascii', 'content' => 'Attachment 2 content created at: ' . Util::getTimestamp()]; $statements = [['actor' => ['mbox' => COMMON_MBOX], 'verb' => ['id' => COMMON_VERB_ID], 'object' => new Activity(['id' => COMMON_ACTIVITY_ID]), 'attachments' => [$attachment1]], ['actor' => ['mbox' => COMMON_MBOX], 'verb' => ['id' => COMMON_VERB_ID], 'object' => new Activity(['id' => COMMON_ACTIVITY_ID . '/2']), 'attachments' => [$attachment1, $attachment2]]]; $response = $lrs->saveStatements($statements); $this->assertInstanceOf('TinCan\\LRSResponse', $response); $this->assertTrue($response->success, 'success'); $this->assertTrue(is_array($response->content), 'content is array'); $this->assertSame(count($response->content), 2, 'content has 2 values'); foreach ($response->content as $i => $st) { $this->assertInstanceof('TinCan\\Statement', $st, "{$i}: is statement"); $id = $st->getId(); $this->assertTrue(isset($id), "{$i}: id set"); } }
public function stamp() { $this->setId(Util::getUUID()); $this->setTimestamp(Util::getTimestamp()); return $this; }