2010-10-05 21:44:30 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* This file is part of the WebServiceBundle.
|
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Bundle\WebServiceBundle\Tests;
|
|
|
|
|
2010-10-05 22:42:47 +02:00
|
|
|
|
2010-10-05 21:44:30 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
|
|
|
use Bundle\WebServiceBundle\SoapKernel;
|
2010-10-05 22:42:47 +02:00
|
|
|
use Bundle\WebServiceBundle\Soap\SoapRequest;
|
|
|
|
use Bundle\WebServiceBundle\Soap\SoapResponse;
|
2010-10-05 21:44:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UnitTest for \Bundle\WebServiceBundle\SoapKernel.
|
|
|
|
*
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
|
|
|
*/
|
|
|
|
class SoapKernelTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-10-05 22:42:47 +02:00
|
|
|
private static $soapRequestContent = '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/"><soapenv:Header/><soapenv:Body><ns1:math_multiply><a>10</a><b>20</b></ns1:math_multiply></soapenv:Body></soapenv:Envelope>';
|
2010-10-05 23:22:12 +02:00
|
|
|
private static $soapResponseContent = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/"><SOAP-ENV:Body><ns1:math_multiplyResponse><result>200</result></ns1:math_multiplyResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>';
|
2010-10-05 22:42:47 +02:00
|
|
|
|
2010-10-05 21:44:30 +02:00
|
|
|
private $soapKernel;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
2010-10-05 22:42:47 +02:00
|
|
|
$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, $httpKernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testHandle()
|
|
|
|
{
|
|
|
|
$response = $this->soapKernel->handle(new SoapRequest(self::$soapRequestContent));
|
2010-10-05 21:44:30 +02:00
|
|
|
|
2010-10-05 22:42:47 +02:00
|
|
|
$this->assertEquals(200, $response->getReturnValue());
|
2010-10-05 23:22:12 +02:00
|
|
|
$this->assertXmlStringEqualsXmlString(self::$soapResponseContent, $response->getContent());
|
2010-10-05 21:44:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException
|
|
|
|
*/
|
2010-10-05 22:42:47 +02:00
|
|
|
public function testHandleWithInvalidRequest()
|
2010-10-05 21:44:30 +02:00
|
|
|
{
|
|
|
|
$this->soapKernel->handle(new Request());
|
|
|
|
}
|
|
|
|
}
|