public function testFromJSONInstantiations()
 {
     $common_activity = new TinCan\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");
 }
Example #2
0
 public function testRetrieveActivity()
 {
     $testActivity = new TinCan\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 TinCan\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');
 }