public function testFromJSONInstantiations()
 {
     $common_activity = new Activity(self::$common_activity_cfg);
     $all_json = array();
     foreach (self::$listProps as $k) {
         $getMethod = 'get' . ucfirst($k);
         $prop_json = '"' . $k . '":[' . json_encode($common_activity->asVersion('1.0.0')) . ']';
         array_push($all_json, $prop_json);
         $obj = ContextActivities::fromJSON('{' . $prop_json . '}');
         $this->assertInstanceOf('TinCan\\ContextActivities', $obj);
         $this->assertEquals([$common_activity], $obj->{$getMethod}(), "{$k} list");
     }
     $obj = ContextActivities::fromJSON('{' . join(",", $all_json) . "}");
     $this->assertInstanceOf('TinCan\\ContextActivities', $obj);
     $this->assertEquals([$common_activity], $obj->getCategory(), "all props: category list");
     $this->assertEquals([$common_activity], $obj->getParent(), "all props: parent list");
     $this->assertEquals([$common_activity], $obj->getGrouping(), "all props: grouping list");
     $this->assertEquals([$common_activity], $obj->getOther(), "all props: other list");
 }
예제 #2
0
 public function testAsVersion()
 {
     $obj = new Activity(array('id' => COMMON_ACTIVITY_ID));
     $versioned = $obj->asVersion('1.0.0');
     $this->assertEquals($versioned, ['objectType' => 'Activity', 'id' => COMMON_ACTIVITY_ID], "id only: 1.0.0");
 }
예제 #3
0
 public function testRetrieveActivity()
 {
     $testActivity = new Activity(['id' => COMMON_ACTIVITY_ID . '/testRetrieveActivity', 'definition' => ['name' => ['en' => 'This is a test activity.']]]);
     $lrs = new RemoteLRS(self::$endpoint, self::$version, self::$username, self::$password);
     $statement = new Statement(['actor' => ['mbox' => COMMON_MBOX], 'verb' => ['id' => COMMON_VERB_ID], 'object' => $testActivity]);
     $response = $lrs->saveStatement($statement);
     $response = $lrs->retrieveActivity($testActivity->getId());
     $this->assertInstanceOf('TinCan\\LRSResponse', $response);
     $this->assertEquals($testActivity, $response->content, 'retrieved activity');
 }