public function testReadEmpty() { $reader = new Json(); $message = new Message(array(), ''); $json = $reader->read($message); $this->assertNull($json); }
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); }