Skip to content

Commit

Permalink
Added tests to use Xml with SOAP.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Sep 2, 2010
1 parent a1eeb03 commit 9239caa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cake/tests/cases/libs/xml.test.php
Expand Up @@ -489,6 +489,38 @@ public function testXmlRpc() {
$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
*
Expand Down
12 changes: 12 additions & 0 deletions cake/tests/fixtures/soap_request.xml
@@ -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 changes: 12 additions & 0 deletions cake/tests/fixtures/soap_response.xml
@@ -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>

0 comments on commit 9239caa

Please sign in to comment.