[\s]{1,}<)/', '', $xmlstring);
return $xmlstring;
}
function testConstructor()
{
$wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
'' .
'' );
}
function testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes()
{
$wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
$wsdl->setUri('http://localhost/MyNewService.php');
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
'' .
'' );
}
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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. '' );
}
function testAddPortType()
{
$wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
$wsdl->addPortType('myPortType');
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
'' .
''
. ''
. '' );
}
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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
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()),
'' .
''
. ''
. ''
. '' );
}
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('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
);
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
$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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
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()),
'' .
''
. ''
. 'This is a description for Port Type node.'
. ''
. '' );
}
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(
'' .
''
. ''
. 'foo'
. ''
. ''
. ''
. ''
. '',
$this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml())
);
}
function testToXml()
{
$wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
'' .
'' );
}
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()),
'' .
'' );
}
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),
'' .
'' );
$wsdl->dump(dirname(__FILE__) . '/_files/dumped.wsdl');
$dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl');
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dumpedContent),
'' .
'' );
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:float', $wsdl->getType('double'), 'xsd:float 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()),
'' .
''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. ''
. '' );
}
/**
* @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:float", $wsdl->getType("douBLE"));
}
/**
* @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;
}