public function testProperties() { $str_datetime = '2014-12-15T19:16:05+00:00'; $str_datetime_tz = '2014-12-15T13:16:05-06:00'; $datetime = new \DateTime(); $datetime->setDate(2014, 12, 15); $datetime->setTime(19, 16, 05); $statement = new Statement(); $statement->setStored($datetime); $statement->setTimestamp($datetime); $document = new State(); $document->setTimestamp($datetime); $this->assertEquals($statement->getStored(), $str_datetime, 'stored matches'); $this->assertEquals($statement->getTimestamp(), $str_datetime, 'timestamp matches'); $this->assertEquals($document->getTimestamp(), $str_datetime, 'document timestamp matches'); $datetime->setTimezone(new DateTimeZone('America/Chicago')); $statement->setStored($datetime); $statement->setTimestamp($datetime); $document->setTimestamp($datetime); $this->assertEquals($statement->getStored(), $str_datetime_tz, 'stored matches'); $this->assertEquals($statement->getTimestamp(), $str_datetime_tz, 'timestamp matches'); $this->assertEquals($document->getTimestamp(), $str_datetime_tz, 'document timestamp matches'); }
public function testAsVersion() { $args = ['actor' => ['mbox' => COMMON_MBOX, 'objectType' => 'Agent'], 'verb' => ['id' => COMMON_VERB_ID, 'display' => ['en-US' => 'experienced']], 'object' => ['objectType' => 'Activity', 'id' => COMMON_ACTIVITY_ID, 'definition' => ['type' => 'Invalid type', 'name' => ['en-US' => 'Test'], 'extensions' => ['http://someuri' => 'some value']]], 'context' => ['contextActivities' => ['parent' => [['objectType' => 'Activity', 'id' => COMMON_ACTIVITY_ID . '/1', 'definition' => ['name' => ['en-US' => 'Test: 1']]]]], 'registration' => TinCan\Util::getUUID()], 'result' => ['completion' => true, 'success' => false, 'score' => ['raw' => '97', 'min' => '65', 'max' => '100', 'scaled' => '.97']], 'version' => '1.0.0', 'attachments' => [['usageType' => 'http://test', 'display' => ['en-US' => 'test display'], 'contentType' => 'text/plain; charset=ascii', 'length' => 0, 'sha2' => hash('sha256', json_encode(['foo', 'bar']))]]]; $obj = new Statement($args); $obj->stamp(); $args['id'] = $obj->getId(); $args['timestamp'] = $obj->getTimestamp(); $obj->getTarget()->getDefinition()->getDescription()->set('en-ES', 'Testo descriptiono'); $args['object']['definition']['description'] = ['en-ES' => 'Testo descriptiono']; $obj->getTarget()->getDefinition()->getName()->unset('en-US'); unset($args['object']['definition']['name']); $versioned = $obj->asVersion('1.0.0'); $this->assertEquals($args, $versioned, 'version 1.0.0'); }