| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Soap
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /** Zend_Soap_Wsdl */
- require_once 'Zend/Soap/Wsdl.php';
- /**
- * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence
- */
- require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php';
- /**
- * Test cases for Zend_Soap_Wsdl
- *
- * @category Zend
- * @package Zend_Soap
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Soap
- * @group Zend_Soap_Wsdl
- */
- class Zend_Soap_WsdlTest extends PHPUnit_Framework_TestCase
- {
- protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring)
- {
- $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring);
- $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring);
- return $xmlstring;
- }
- function testConstructor()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' );
- }
- function testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->setUri('http://localhost/MyNewService.php');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyNewService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyNewService.php"/>' );
- }
- function testAddMessage()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $messageParts = array();
- $messageParts['parameter1'] = $wsdl->getType('int');
- $messageParts['parameter2'] = $wsdl->getType('string');
- $messageParts['parameter3'] = $wsdl->getType('mixed');
- $wsdl->addMessage('myMessage', $messageParts);
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<message name="myMessage">'
- . '<part name="parameter1" type="xsd:int"/>'
- . '<part name="parameter2" type="xsd:string"/>'
- . '<part name="parameter3" type="xsd:anyType"/>'
- . '</message>'
- . '</definitions>' );
- }
- function testAddPortType()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '</definitions>' );
- }
- function testAddPortOperation()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $portType = $wsdl->addPortType('myPortType');
- $wsdl->addPortOperation($portType, 'operation1');
- $wsdl->addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response');
- $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType">'
- . '<operation name="operation1"/>'
- . '<operation name="operation2">'
- . '<input message="tns:operation2Request"/>'
- . '<output message="tns:operation2Response"/>'
- . '</operation>'
- . '<operation name="operation3">'
- . '<input message="tns:operation3Request"/>'
- . '<output message="tns:operation3Response"/>'
- . '<fault message="tns:operation3Fault"/>'
- . '</operation>'
- . '</portType>'
- . '</definitions>' );
- }
- function testAddBinding()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $wsdl->addBinding('MyServiceBinding', 'myPortType');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType"/>'
- . '</definitions>' );
- }
- function testAddBindingOperation()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType');
- $wsdl->addBindingOperation($binding, 'operation1');
- $wsdl->addBindingOperation($binding,
- 'operation2',
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
- );
- $wsdl->addBindingOperation($binding,
- 'operation3',
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('name' => 'MyFault', 'use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
- );
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType">'
- . '<operation name="operation1"/>'
- . '<operation name="operation2">'
- . '<input>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</input>'
- . '<output>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</output>'
- . '</operation>'
- . '<operation name="operation3">'
- . '<input>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</input>'
- . '<output>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</output>'
- . '<fault name="MyFault">'
- . '<soap:fault name="MyFault" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</fault>'
- . '</operation>'
- . '</binding>'
- . '</definitions>' );
- }
- function testAddSoapBinding()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType');
- $wsdl->addSoapBinding($binding);
- $wsdl->addBindingOperation($binding, 'operation1');
- $wsdl->addBindingOperation($binding,
- 'operation2',
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
- );
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType">'
- . '<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>'
- . '<operation name="operation1"/>'
- . '<operation name="operation2">'
- . '<input>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</input>'
- . '<output>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</output>'
- . '</operation>'
- . '</binding>'
- . '</definitions>' );
- $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl1->addPortType('myPortType');
- $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType');
- $wsdl1->addSoapBinding($binding, 'rpc');
- $wsdl1->addBindingOperation($binding, 'operation1');
- $wsdl1->addBindingOperation($binding,
- 'operation2',
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
- );
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl1->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType">'
- . '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'
- . '<operation name="operation1"/>'
- . '<operation name="operation2">'
- . '<input>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</input>'
- . '<output>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</output>'
- . '</operation>'
- . '</binding>'
- . '</definitions>' );
- }
- function testAddSoapOperation()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType');
- $wsdl->addSoapOperation($binding, 'http://localhost/MyService.php#myOperation');
- $wsdl->addBindingOperation($binding, 'operation1');
- $wsdl->addBindingOperation($binding,
- 'operation2',
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
- );
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType">'
- . '<soap:operation soapAction="http://localhost/MyService.php#myOperation"/>'
- . '<operation name="operation1"/>'
- . '<operation name="operation2">'
- . '<input>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</input>'
- . '<output>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
- . '</output>'
- . '</operation>'
- . '</binding>'
- . '</definitions>' );
- }
- function testAddService()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addPortType('myPortType');
- $wsdl->addBinding('MyServiceBinding', 'myPortType');
- $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType"/>'
- . '<binding name="MyServiceBinding" type="myPortType"/>'
- . '<service name="Service1">'
- . '<port name="myPortType" binding="MyServiceBinding">'
- . '<soap:address location="http://localhost/MyService.php"/>'
- . '</port>'
- . '</service>'
- . '</definitions>' );
- }
- function testAddDocumentation()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $portType = $wsdl->addPortType('myPortType');
- $wsdl->addDocumentation($portType, 'This is a description for Port Type node.');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<portType name="myPortType">'
- . '<documentation>This is a description for Port Type node.</documentation>'
- . '</portType>'
- . '</definitions>' );
- }
- public function testAddDocumentationToSetInsertsBefore()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $messageParts = array();
- $messageParts['parameter1'] = $wsdl->getType('int');
- $messageParts['parameter2'] = $wsdl->getType('string');
- $messageParts['parameter3'] = $wsdl->getType('mixed');
- $message = $wsdl->addMessage('myMessage', $messageParts);
- $wsdl->addDocumentation($message, "foo");
- $this->assertEquals(
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<message name="myMessage">'
- . '<documentation>foo</documentation>'
- . '<part name="parameter1" type="xsd:int"/>'
- . '<part name="parameter2" type="xsd:string"/>'
- . '<part name="parameter3" type="xsd:anyType"/>'
- . '</message>'
- . '</definitions>',
- $this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml())
- );
- }
- function testToXml()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' );
- }
- function testToDomDocument()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $dom = $wsdl->toDomDocument();
- $this->assertTrue($dom instanceOf DOMDocument);
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' );
- }
- function testDump()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- ob_start();
- $wsdl->dump();
- $wsdlDump = ob_get_clean();
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdlDump),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' );
- $wsdl->dump(dirname(__FILE__) . '/_files/dumped.wsdl');
- $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dumpedContent),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' );
- unlink(dirname(__FILE__) . '/_files/dumped.wsdl');
- }
- function testGetType()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', true);
- $this->assertEquals('xsd:string', $wsdl->getType('string'), 'xsd:string detection failed.');
- $this->assertEquals('xsd:string', $wsdl->getType('str'), 'xsd:string detection failed.');
- $this->assertEquals('xsd:int', $wsdl->getType('int'), 'xsd:int detection failed.');
- $this->assertEquals('xsd:int', $wsdl->getType('integer'), 'xsd:int detection failed.');
- $this->assertEquals('xsd:float', $wsdl->getType('float'), 'xsd:float detection failed.');
- $this->assertEquals('xsd:double', $wsdl->getType('double'), 'xsd:double detection failed.');
- $this->assertEquals('xsd:boolean', $wsdl->getType('boolean'), 'xsd:boolean detection failed.');
- $this->assertEquals('xsd:boolean', $wsdl->getType('bool'), 'xsd:boolean detection failed.');
- $this->assertEquals('soap-enc:Array', $wsdl->getType('array'), 'soap-enc:Array detection failed.');
- $this->assertEquals('xsd:struct', $wsdl->getType('object'), 'xsd:struct detection failed.');
- $this->assertEquals('xsd:anyType', $wsdl->getType('mixed'), 'xsd:anyType detection failed.');
- $this->assertEquals('', $wsdl->getType('void'), 'void detection failed.');
- }
- function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', true);
- $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test'));
- $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType);
- $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', false);
- $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test'));
- $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType);
- }
- function testGetComplexTypeBasedOnStrategiesStringNames()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_DefaultComplexType');
- $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test'));
- $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType);
- $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_AnyType');
- $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test'));
- $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType);
- }
- function testSettingUnknownStrategyThrowsException()
- {
- try {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_UnknownStrategyType');
- $this->fail();
- } catch(Zend_Soap_Wsdl_Exception $e) {
- }
- }
- function testSettingInvalidStrategyObjectThrowsException()
- {
- try {
- $strategy = new Zend_Soap_Wsdl_Test();
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $strategy);
- $this->fail();
- } catch(Zend_Soap_Wsdl_Exception $e) {
- }
- }
- function testAddingSameComplexTypeMoreThanOnceIsIgnored()
- {
- try {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addType('Zend_Soap_Wsdl_Test');
- $wsdl->addType('Zend_Soap_Wsdl_Test');
- $types = $wsdl->getTypes();
- $this->assertEquals(1, count($types));
- $this->assertEquals(array("Zend_Soap_Wsdl_Test"), $types);
- } catch(Zend_Soap_Wsdl_Exception $e) {
- $this->fail();
- }
- }
- function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addComplexType('Zend_Soap_Wsdl_Test');
- $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes());
- $wsdl->addComplexType('Zend_Soap_Wsdl_Test');
- $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes());
- }
- function testAddComplexType()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $wsdl->addComplexType('Zend_Soap_Wsdl_Test');
- $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
- '<?xml version="1.0"?>' .
- '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
- . 'xmlns:tns="http://localhost/MyService.php" '
- . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" '
- . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
- . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" '
- . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" '
- . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
- . '<types>'
- . '<xsd:schema targetNamespace="http://localhost/MyService.php">'
- . '<xsd:complexType name="Zend_Soap_Wsdl_Test">'
- . '<xsd:all>'
- . '<xsd:element name="var1" type="xsd:int" nillable="true"/>'
- . '<xsd:element name="var2" type="xsd:string" nillable="true"/>'
- . '</xsd:all>'
- . '</xsd:complexType>'
- . '</xsd:schema>'
- . '</types>'
- . '</definitions>' );
- }
- /**
- * @group ZF-3910
- */
- function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $this->assertEquals("xsd:string", $wsdl->getType("StrIng"));
- $this->assertEquals("xsd:string", $wsdl->getType("sTr"));
- $this->assertEquals("xsd:int", $wsdl->getType("iNt"));
- $this->assertEquals("xsd:int", $wsdl->getType("INTEGER"));
- $this->assertEquals("xsd:float", $wsdl->getType("FLOAT"));
- $this->assertEquals("xsd:double", $wsdl->getType("douBLE"));
- }
- /**
- * @group ZF-11937
- */
- public function testWsdlGetTypeWillAllowLongType()
- {
- $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
- $this->assertEquals("xsd:long", $wsdl->getType("long"));
- }
- /**
- * @group ZF-5430
- */
- public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy()
- {
- $wsdl = new Zend_Soap_Wsdl("MyService", "http://localhost/MyService.php");
- $wsdl->setComplexTypeStrategy(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence());
- $wsdl->addComplexType("string[]");
- $wsdl->addComplexType("int[]");
- $wsdl->addComplexType("string[]");
- $xml = $wsdl->toXml();
- $this->assertEquals(1, substr_count($xml, "ArrayOfString"), "ArrayOfString should appear only once.");
- $this->assertEquals(1, substr_count($xml, "ArrayOfInt"), "ArrayOfInt should appear only once.");
- }
- const URI_WITH_EXPANDED_AMP = "http://localhost/MyService.php?a=b&b=c";
- const URI_WITHOUT_EXPANDED_AMP = "http://localhost/MyService.php?a=b&b=c";
- /**
- * @group ZF-5736
- */
- public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly()
- {
- $wsdl = new Zend_Soap_Wsdl("MyService", self::URI_WITH_EXPANDED_AMP);
- $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML());
- }
- /**
- * @group ZF-5736
- */
- public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly()
- {
- $wsdl = new Zend_Soap_Wsdl("MyService", "http://example.com");
- $wsdl->setUri(self::URI_WITH_EXPANDED_AMP);
- $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML());
- }
- }
- /**
- * Test Class
- */
- class Zend_Soap_Wsdl_Test {
- /**
- * @var integer
- */
- public $var1;
- /**
- * @var string
- */
- public $var2;
- }
|