Added tests to use Xml with SOAP.

This commit is contained in:
Juan Basso 2010-09-01 21:37:32 -03:00
parent a1eeb03e36
commit 9239caa589
3 changed files with 56 additions and 0 deletions

View file

@ -489,6 +489,38 @@ class XmlTest extends CakeTestCase {
$this->assertEqual(str_replace(array("\r", "\n"), '', $xml->asXML()), $xmlText);
}
/**
* testSoap
*
* @return void
*/
public function testSoap() {
$xmlRequest = Xml::build(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'soap_request.xml');
$expected = array(
'Envelope' => array(
'@encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding',
'Body' => array(
'GetStockPrice' => array(
'StockName' => 'IBM'
)
)
)
);
$this->assertEqual(Xml::toArray($xmlRequest), $expected);
$xmlResponse = Xml::build(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'soap_response.xml');
$expected = array(
'Envelope' => array(
'@encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding',
'Body' => array(
'GetStockPriceResponse' => array(
'Price' => '34.5'
)
)
)
);
}
/**
* data provider for toArray() failures
*

12
cake/tests/fixtures/soap_request.xml vendored Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

12
cake/tests/fixtures/soap_response.xml vendored Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>