예제 #1
0
파일: JsonTest.php 프로젝트: seytar/psx
 public function testReadEmpty()
 {
     $reader = new Json();
     $message = new Message(array(), '');
     $json = $reader->read($message);
     $this->assertNull($json);
 }
예제 #2
0
 public function testGet()
 {
     $url = new Url($this->getEndpoint());
     $url->addParam('format', 'jas');
     $response = $this->signedRequest('GET', $url);
     $this->assertEquals(200, $response->getCode());
     // check result
     $result = Json::decode($response->getBody());
     $this->assertArrayHasKey('itemsPerPage', $result, $response->getBody());
     $this->assertArrayHasKey('startIndex', $result, $response->getBody());
     $this->assertArrayHasKey('items', $result, $response->getBody());
     $this->assertEquals(true, count($result['items']) > 0);
     foreach ($result['items'] as $activity) {
         $this->assertArrayHasKey('actor', $activity);
         $this->assertArrayHasKey('object', $activity);
         $this->assertArrayHasKey('verb', $activity);
     }
     // try to create activitystream object
     $reader = new Reader\Json();
     $result = $reader->read($response);
     $collection = new Collection();
     $collection->import($result);
     $this->assertInstanceOf('PSX\\ActivityStream\\Collection', $collection);
 }