diff --git a/tests/Zend/Soap/WSDL/ElementTest.php b/tests/Zend/Soap/WSDL/ElementTest.php deleted file mode 100644 index b63bdbaa97f..00000000000 --- a/tests/Zend/Soap/WSDL/ElementTest.php +++ /dev/null @@ -1,245 +0,0 @@ -assertEquals("name1", $binding->getName()); - $this->assertEquals("port1", $binding->portName); - $this->assertEquals($operations, $binding->operations); - $this->assertEquals("test", $binding->getDocumentation()); - - try { - $binding = new WSDL\Element\Binding(array(), "portName", $operations, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testTypeElementApi() - { - $types = new WSDL\Element\Collection("test"); - $type = new WSDL\Element\Type("name1", $types, "test"); - - $this->assertEquals("name1", $type->getName()); - $this->assertEquals($types, $type->types); - $this->assertEquals("test", $type->getDocumentation()); - - try { - $type = new WSDL\Element\Type(array(), $types, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testMessageElementApi() - { - $parts = new WSDL\Element\Collection("test"); - $message = new WSDL\Element\Message("name1", $parts, "test"); - - $this->assertEquals("name1", $message->getName()); - $this->assertEquals($parts, $message->parts); - $this->assertEquals("test", $message->getDocumentation()); - - try { - $message = new WSDL\Element\Message(array(), $parts, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testPortElementApi() - { - $operations = new WSDL\Element\Collection("test"); - $port = new WSDL\Element\Port("name1", $operations, "test"); - - $this->assertEquals("name1", $port->getName()); - $this->assertEquals($operations, $port->operations); - $this->assertEquals("test", $port->getDocumentation()); - - try { - $port = new WSDL\Element\Port(array(), $operations, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testOperationElementApi() - { - $collection = new WSDL\Element\Collection("test"); - $input = new WSDL\Element\Message("name", $collection, "test"); - $output = new WSDL\Element\Message("name", $collection, "test"); - - $operation = new WSDL\Element\Operation("name1", $input, $output, "test"); - - $this->assertEquals("name1", $operation->getName()); - $this->assertEquals($input, $operation->inputMessage); - $this->assertEquals($output, $operation->outputMessage); - $this->assertEquals("test", $operation->getDocumentation()); - - try { - $operation = new WSDL\Element\Operation(array(), $input, $output, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testServiceElementApi() - { - $collection = new WSDL\Element\Collection("test"); - $port = new WSDL\Element\Port("name", $collection, "test"); - $binding = new WSDL\Element\Binding("name", "port", $collection, "test"); - - $service = new WSDL\Element\Service("service", "address", $port, $binding, "test"); - - $this->assertEquals("service", $service->getName()); - $this->assertEquals("address", $service->soapAddress); - $this->assertEquals($port, $service->port); - $this->assertEquals($binding, $service->binding); - $this->assertEquals("test", $service->getDocumentation()); - - try { - $service = new WSDL\Element\Service(array(), "address", $port, $binding, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - - try { - $service = new WSDL\Element\Service("name", array(), $port, $binding, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testCollectionElementApiConstruct() - { - $collection = new WSDL\Element\Collection("Operation"); - - $this->assertTrue($collection instanceof \Countable); - $this->assertTrue($collection instanceof \Iterator); - - try { - $type = new WSDL\Element\Type("type", new WSDL\Element\Collection("Type"), "test"); - $collection->addElement($type); - $this->fail(); - } catch(WSDLException $e) { - - } - - try { - $collection = new WSDL\Element\Collection(false); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testCollectionElementApiType() - { - $collection = new WSDL\Element\Collection("Operation"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Operation", $collection->getType()); - - $collection = new WSDL\Element\Collection("Type"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Type", $collection->getType()); - - $collection = new WSDL\Element\Collection("Binding"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Binding", $collection->getType()); - - $collection = new WSDL\Element\Collection("Service"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Service", $collection->getType()); - - $collection = new WSDL\Element\Collection("Port"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Port", $collection->getType()); - - $collection = new WSDL\Element\Collection("Message"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Message", $collection->getType()); - } - - public function testCollectionElementApiElementAccess() - { - $collection = new WSDL\Element\Collection("Message"); - $message1 = new WSDL\Element\Message("message1", new WSDL\Element\Collection("Type"), "test"); - $message2 = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); - $messageDuplicate = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); - - $collection->addElement($message1); - $this->assertEquals(array("message1"), $collection->getElementNames()); - $this->assertEquals($message1, $collection->getElement("message1")); - $this->assertEquals(1, count($collection)); - - $collection->addElement($message2); - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - - try { - // Adding duplicate message leads to exception - $collection->addElement($messageDuplicate); - $this->fail("Adding a duplicate named element to a collection should throw an exception."); - } catch(WSDLException $e) { - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - } - - try { - // Accessing unkown message leads to exception - $collection->getElement("messageUnknown"); - $this->fail("Accessing unknown element should throw an exception."); - } catch(WSDLException $e) { - $this->assertEquals(2, count($collection)); - } - - foreach($collection AS $name => $message) { - $this->assertTrue($message instanceof WSDL\Element\Message); - $this->assertTrue( in_array($name, $collection->getElementNames()) ); - } - } -} diff --git a/tests/Zend/Soap/WSDL/ParserTest.php b/tests/Zend/Soap/WSDL/ParserTest.php deleted file mode 100644 index 3499913d61e..00000000000 --- a/tests/Zend/Soap/WSDL/ParserTest.php +++ /dev/null @@ -1,191 +0,0 @@ -loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl")); - return $dom; - } - - public function testFactoryWithDomDocument() - { - $dom = $this->getWSDLExampleDom(); - $parser = WSDL\Parser::factory($dom); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithString() - { - $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); - $parser = WSDL\Parser::factory($xmlString); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithSimpleXml() - { - $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); - $simpleXml = simplexml_load_string($xmlString); - $parser = WSDL\Parser::factory($simpleXml); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithZendSoapWSDL() - { - $wsdl = new WSDL("name", "http://example.com"); - $parser = WSDL\Parser::factory($wsdl); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithInvalidParser() - { - $wsdl = new WSDL("name", "http://example.com"); - try { - $parser = WSDL\Parser::factory($wsdl, "stdClass"); - $this->fail(); - } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Parser\Exception); - } - } - - public function testFactoryWithInvalidData() - { - try { - $parser = WSDL\Parser::factory(null); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testParserApiInterface() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - // SetWSDL is a fluent function - $this->assertTrue( ($parser->setDomDocumentContainingWSDL($dom)) instanceof WSDL\Parser ); - - // Parse returns Result - $result = $parser->parse(); - $this->assertTrue($result instanceof WSDL\Parser\Result); - } - - public function testParserResultApiInterface() - { - $result = new WSDL\Parser\Result( - "name", - WSDL\Parser::WSDL_11, - new WSDL\Element_Collection("Operation"), - new WSDL\Element_Collection("Port"), - new WSDL\Element_Collection("Binding"), - new WSDL\Element_Collection("Service"), - new WSDL\Element_Collection("Type"), - array("docs") - ); - - $this->assertEquals("name", $result->getName()); - $this->assertEquals("Zend_Soap_WSDL_Element_Operation", $result->operations->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Port", $result->ports->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Binding", $result->bindings->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Service", $result->services->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Type", $result->types->getType()); - $this->assertEquals(array("docs"), $result->documentation); - - try { - $key = $result->invalidKeyThrowsException; - $this->fail(); - } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Parser\Exception); - } - } - - public function testParseExampleWSDLAndCountResultElements() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - $result = $parser->parse(); - - $this->assertEquals("Zend_Soap_Server_TestClass", $result->getName()); - $this->assertEquals(WSDL\Parser::WSDL_11, $result->getVersion()); - $this->assertEquals(4, count($result->operations), "Number of operations does not match."); - $this->assertEquals(1, count($result->bindings), "Number of bindings does not match."); - $this->assertEquals(1, count($result->ports), "Number of ports does not match."); - $this->assertEquals(1, count($result->services), "Number of services does not match."); - $this->assertEquals(0, count($result->types), "Number of types does not match."); - $this->assertEquals(4, count($result->bindings->current()->operations), "Number of operations in the bindings collection does not match."); - $this->assertEquals(4, count($result->ports->current()->operations), "Number of operations in the ports collection does not match."); - } - - public function testParseExampleWSDLAndCheckMatchingNames() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - $result = $parser->parse(); - - foreach($result->operations AS $operation) { - $this->assertContains($operation->getName(), array("testFunc1", "testFunc2", "testFunc3", "testFunc4")); - } - foreach($result->bindings AS $binding) { - $this->assertEquals("Zend_Soap_Server_TestClassBinding", $binding->getName()); - } - foreach($result->ports AS $port) { - $this->assertEquals("Zend_Soap_Server_TestClassPort", $port->getName()); - } - foreach($result->services AS $service) { - $this->assertEquals("Zend_Soap_Server_TestClassService", $service->getName()); - } - } - - public function testParseExampleWSDLWithDocumentationBlocks() - { - $dom = new \DOMDocument(); - $dom->loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_documentation.wsdl")); - - $parser = new WSDL\Parser($dom); - $result = $parser->parse(); - } -}