diff --git a/SoapKernel.php b/SoapKernel.php
index 08f88a9..4441d31 100644
--- a/SoapKernel.php
+++ b/SoapKernel.php
@@ -18,7 +18,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Bundle\WebServiceBundle\Soap\SoapRequest;
use Bundle\WebServiceBundle\Soap\SoapResponse;
-use Bundle\WebServiceBundle\Util\OutputBuffer;
use Bundle\WebServiceBundle\Util\String;
/**
@@ -68,12 +67,11 @@ class SoapKernel implements HttpKernelInterface
{
$this->soapRequest = $this->checkRequest($request);
- $this->soapResponse->setContent(OutputBuffer::get(
- function() use($this)
- {
- $this->soapServer->handle($this->soapRequest->getRawContent());
- }
- ));
+ ob_start();
+ $this->soapServer->handle($this->soapRequest->getRawContent());
+
+ $soapResponseContent = ob_get_clean();
+ $this->soapResponse->setContent($soapResponseContent);
return $this->soapResponse;
}
@@ -121,7 +119,7 @@ class SoapKernel implements HttpKernelInterface
if(!is_a($request, __NAMESPACE__ . '\\Soap\\SoapRequest'))
{
- throw new InvalidArgumentException();
+ throw new \InvalidArgumentException();
}
return $request;
@@ -138,9 +136,9 @@ class SoapKernel implements HttpKernelInterface
*/
protected function checkResponse(Response $response)
{
- if($response == null || !is_a($request, __NAMESPACE__ . '\\Soap\\SoapResponse'))
+ if($response == null || !is_a($response, __NAMESPACE__ . '\\Soap\\SoapResponse'))
{
- throw new InvalidArgumentException();
+ throw new \InvalidArgumentException();
}
return $response;
diff --git a/Tests/SoapKernelTest.php b/Tests/SoapKernelTest.php
index b1b6098..47aa0e9 100644
--- a/Tests/SoapKernelTest.php
+++ b/Tests/SoapKernelTest.php
@@ -10,9 +10,12 @@
namespace Bundle\WebServiceBundle\Tests;
+
use Symfony\Component\HttpFoundation\Request;
use Bundle\WebServiceBundle\SoapKernel;
+use Bundle\WebServiceBundle\Soap\SoapRequest;
+use Bundle\WebServiceBundle\Soap\SoapResponse;
/**
* UnitTest for \Bundle\WebServiceBundle\SoapKernel.
@@ -21,19 +24,34 @@ use Bundle\WebServiceBundle\SoapKernel;
*/
class SoapKernelTest extends \PHPUnit_Framework_TestCase
{
+ private static $soapRequestContent = '1020';
+ private static $soapResponseContent = '200';
+
private $soapKernel;
public function setUp()
{
- $soapServer = new \SoapServer();
+ $soapServer = new \SoapServer(__DIR__ . '/fixtures/api.wsdl');
+ $httpKernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
+ $httpKernel->expects($this->any())
+ ->method('handle')
+ ->will($this->returnValue(new SoapResponse(200)));
- $this->soapKernel = new SoapKernel($soapServer, null);
+ $this->soapKernel = new SoapKernel($soapServer, $httpKernel);
+ }
+
+ public function testHandle()
+ {
+ $response = $this->soapKernel->handle(new SoapRequest(self::$soapRequestContent));
+
+ $this->assertEquals(200, $response->getReturnValue());
+ $this->assertEquals(self::$soapResponseContent, $response->getContent());
}
/**
* @expectedException InvalidArgumentException
*/
- public function testInvalidRequest()
+ public function testHandleWithInvalidRequest()
{
$this->soapKernel->handle(new Request());
}
diff --git a/Tests/fixtures/api.wsdl b/Tests/fixtures/api.wsdl
new file mode 100644
index 0000000..c20abed
--- /dev/null
+++ b/Tests/fixtures/api.wsdl
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Util/OutputBuffer.php b/Util/OutputBuffer.php
deleted file mode 100644
index d40ccc6..0000000
--- a/Util/OutputBuffer.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Bundle\WebServiceBundle\Util;
-
-/**
- * OutputBuffer provides utility methods to work with PHP's output buffer.
- *
- * @author Christian Kerl
- */
-class OutputBuffer
-{
- /**
- * Gets the output created by the given callable.
- *
- * @param callable $callback A callable to execute
- *
- * @return string The output
- */
- static public function get($callback)
- {
- ob_start();
- $callback();
- return ob_get_clean();
- }
-}
\ No newline at end of file