assertRegExp('/xml could not be parsed/i', $e->getMessage());
}
}
public function testThrowsWhenXmlElementNameIsNotResponse()
{
$xml = "
";
try {
new Zend_Service_Nirvanix_Response($xml);
} catch (Zend_Service_Nirvanix_Exception $e) {
$this->assertRegExp('/expected xml element response/i', $e->getMessage());
}
}
public function testThrowsCodeAndMessageWhenResponseCodeIsNotZero()
{
$xml = "
42
foo
";
try {
new Zend_Service_Nirvanix_Response($xml);
} catch (Zend_Service_Nirvanix_Exception $e) {
$this->assertEquals(42, $e->getCode());
$this->assertEquals('foo', $e->getMessage());
}
}
// getSxml()
public function testGetSxmlReturnsSimpleXmlElement()
{
$xml = "
0
bar
";
$resp = new Zend_Service_Nirvanix_Response($xml);
$this->assertType('SimpleXMLElement', $resp->getSxml());
}
// __get()
public function testUndefinedPropertyIsDelegatedToSimpleXMLElement()
{
$xml = "
0
bar
";
$resp = new Zend_Service_Nirvanix_Response($xml);
$this->assertEquals('bar', (string)$resp->foo);
}
// __call()
public function testUndefinedMethodIsDelegatedToSimpleXMLElement()
{
$xml = "
0
bar
";
$resp = new Zend_Service_Nirvanix_Response($xml);
$this->assertEquals('Response', $resp->getName());
}
}