public function testSetResources() { $client = $this->getMockClient(); $fixture = file_get_contents(__DIR__ . '/fixtures/ResourceList.response.xml'); $resourceList = $client::response($fixture); $this->assertInstanceOf(AbstractResponse::ns() . '\\ResourceList', $resourceList); $resources = $resourceList->getResources(); $resourceList->setResources($resources); $this->assertEquals($resources, $resourceList->getResources()); }
/** * Parse a response into a response type * * @static * @param string $data Response data to be parsed * @param string $type = 'xml' Response format * @return mixed Response object */ public static function response($data, $type = self::FORMAT_XML) { if (is_string($data) && strlen($data) === 0) { return true; // Many operations return an empty string for success } switch ($type) { case static::FORMAT_XML: return AbstractResponse::fromXml($data); case static::FORMAT_JSON: return AbstractResponse::fromJson($data); } throw new InvalidArgumentException("Type must be 'xml' or 'json'"); }