Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
[SOAP] Remove Zend\Server\Server interface from Zend\Soap\Autodiscove…
Browse files Browse the repository at this point in the history
…r. It did never make any sense. Renamed Autodiscover#handle() to Autodiscover#generate()
  • Loading branch information
beberlei committed Dec 5, 2011
1 parent 6387438 commit c6a1e6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 101 deletions.
52 changes: 3 additions & 49 deletions library/Zend/Soap/AutoDiscover.php
Expand Up @@ -35,7 +35,7 @@
* @package Zend_Soap
* @subpackage AutoDiscover
*/
class AutoDiscover implements \Zend\Server\Server
class AutoDiscover
{
/**
* @var \Zend\Soap\Wsdl
Expand Down Expand Up @@ -428,23 +428,9 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
}

/**
* Action to take when an error occurs
*
* @param string $fault
* @param string|int $code
* @throws \Zend\Soap\Exception\UnexpectedValueException
*/
public function fault($fault = null, $code = null)
{
throw new Exception\UnexpectedValueException('Function has no use in AutoDiscover.');
}

/**
* Handle the Request
*
* @param string $request A non-standard request - Not Used
* Generate the WSDL file from the configured input.
*/
public function handle($request = false)
public function generate()
{
if (!headers_sent()) {
header('Content-Type: text/xml');
Expand Down Expand Up @@ -483,38 +469,6 @@ public function toXml()
}
}

/**
* Return an array of functions in the WSDL
*
* @return array
*/
public function getFunctions()
{
return $this->_functions;
}

/**
* Load Functions
*
* @param unknown_type $definition
* @throws \Zend\Soap\Exception\RuntimeException
*/
public function loadFunctions($definition)
{
throw new Exception\RuntimeException('Function has no use in AutoDiscover.');
}

/**
* Set Persistance
*
* @param int $mode
* @throws \Zend\Soap\Exception\RuntimeException
*/
public function setPersistence($mode)
{
throw new Exception\RuntimeException('Function has no use in AutoDiscover.');
}

/**
* Returns an XSD Type for the given PHP type
*
Expand Down
66 changes: 14 additions & 52 deletions tests/Zend/Soap/AutoDiscoverTest.php
Expand Up @@ -79,7 +79,7 @@ function testSetClass()
$server->setClass('\ZendTest\Soap\TestAsset\Test');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());

$wsdl = '<?xml version="1.0"?>'
Expand Down Expand Up @@ -170,7 +170,7 @@ function testSetClassWithDifferentStyles()
$server->setClass('\ZendTest\Soap\TestAsset\Test');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());

$wsdl = '<?xml version="1.0"?>'
Expand Down Expand Up @@ -328,7 +328,7 @@ function testSetClassWithResponseReturnPartCompabilityMode()
$server->setClass('\ZendTest\Soap\TestAsset\Test');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());

$dom->save(__DIR__.'/TestAsset/setclass.wsdl');
Expand All @@ -349,7 +349,7 @@ function testAddFunctionSimple()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());
$dom->save(__DIR__.'/TestAsset/addfunction.wsdl');

Expand Down Expand Up @@ -394,7 +394,7 @@ function testAddFunctionSimpleWithDifferentStyle()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());
$dom->save(__DIR__.'/TestAsset/addfunction.wsdl');

Expand Down Expand Up @@ -445,7 +445,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');
$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());
$dom->save(__DIR__.'/TestAsset/addfunction.wsdl');

Expand Down Expand Up @@ -476,7 +476,7 @@ function testAddFunctionMultiple()

$dom = new \DOMDocument();
ob_start();
$server->handle();
$server->generate();
$dom->loadXML(ob_get_clean());
$dom->save(__DIR__.'/TestAsset/addfunction2.wsdl');

Expand Down Expand Up @@ -578,7 +578,7 @@ public function testChangeWsdlUriInConstructor()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertNotContains($scriptUri, $wsdlOutput);
Expand All @@ -597,7 +597,7 @@ public function testChangeWsdlUriViaSetUri()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertNotContains($scriptUri, $wsdlOutput);
Expand All @@ -624,7 +624,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertNotContains($scriptUri, $wsdlOutput);
Expand All @@ -633,7 +633,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible()
$server->setUri("http://example2.com/service2.php");

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertNotContains($scriptUri, $wsdlOutput);
Expand All @@ -654,50 +654,12 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl()
$server->setClass('\ZendTest\Soap\TestAsset\TestFixingMultiplePrototypes');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncIn">'));
$this->assertEquals(1, substr_count($wsdlOutput, '<message name="testFuncOut">'));
}

public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnBadPersistence()
{
$server = $this->createAutodiscoverService();

$this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover');
$server->setPersistence("bogus");
}


public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnFault()
{
$server = $this->createAutodiscoverService();

$this->setExpectedException('Zend\Soap\Exception\UnexpectedValueException', 'Function has no use in AutoDiscover');
$server->fault();
}

public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnLoadFunctionsCall()
{
$server = $this->createAutodiscoverService();

$this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover');
$server->loadFunctions("bogus");
}

public function testGetFunctions()
{
$server = $this->createAutodiscoverService();
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');
$server->setClass('\ZendTest\Soap\TestAsset\Test');

$functions = $server->getFunctions();
$this->assertEquals(
array('ZendTest\Soap\TestAsset\TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'),
$functions
);
}

/**
* @group ZF-4937
Expand All @@ -709,7 +671,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce()
$server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertEquals(1,
Expand Down Expand Up @@ -739,7 +701,7 @@ public function testDumpOrXmlOfAutoDiscover()
$server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');

ob_start();
$server->handle();
$server->generate();
$wsdlOutput = ob_get_clean();

$this->assertEquals(
Expand Down

2 comments on commit c6a1e6b

@jducro
Copy link

@jducro jducro commented on c6a1e6b Dec 15, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to update the documentation : http://framework.zend.com/manual/en/zend.soap.autodiscovery.html ?
The handle function don't exists anymore

@beberlei
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a stable version doc. The docs for this have been updated

Please sign in to comment.