Run mock server in each SoapClient test case & unit test fixed

This commit is contained in:
Petr Bechyně 2018-02-06 00:38:35 +01:00
parent 45cce3a41c
commit e58927469c
2 changed files with 14 additions and 6 deletions

View File

@ -16,12 +16,24 @@ class SoapClientTest extends PHPUnit_Framework_TestCase
{ {
const CACHE_DIR = __DIR__ . '/../../../cache'; const CACHE_DIR = __DIR__ . '/../../../cache';
const FIXTURES_DIR = __DIR__ . '/../../Fixtures'; const FIXTURES_DIR = __DIR__ . '/../../Fixtures';
const TEST_HTTP_URL = 'http://localhost:9000/tests'; const TEST_HTTP_URL = 'http://localhost:8000/tests';
const TEST_ENDPOINT_UK = 'http://www.webservicex.net/uklocation.asmx'; const TEST_ENDPOINT_UK = 'http://www.webservicex.net/uklocation.asmx';
const TEST_REMOTE_WSDL_UK = 'http://www.webservicex.net/uklocation.asmx?WSDL'; const TEST_REMOTE_WSDL_UK = 'http://www.webservicex.net/uklocation.asmx?WSDL';
const TEST_REMOTE_ENDPOINT_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint'; const TEST_REMOTE_ENDPOINT_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint';
const TEST_REMOTE_WSDL_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint?wsdl'; const TEST_REMOTE_WSDL_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint?wsdl';
private $localWebServerProcess;
public function setUp()
{
$this->localWebServerProcess = popen('php -S localhost:8000 > /dev/null 2>&1 &', 'r');
}
public function tearDown()
{
pclose($this->localWebServerProcess);
}
public function testSoapCall() public function testSoapCall()
{ {
$soapClient = $this->getSoapBuilder()->build( $soapClient = $this->getSoapBuilder()->build(
@ -233,8 +245,6 @@ class SoapClientTest extends PHPUnit_Framework_TestCase
*/ */
public function testSoapCallSwaWithAttachmentsOnResponse() public function testSoapCallSwaWithAttachmentsOnResponse()
{ {
$localWebServerProcess = popen('php -S localhost:9000 > /dev/null 2>&1 &', 'r');
$soapClient = $this->getSoapBuilder()->buildWithSoapHeader( $soapClient = $this->getSoapBuilder()->buildWithSoapHeader(
SoapClientOptionsBuilder::createWithTracing(), SoapClientOptionsBuilder::createWithTracing(),
SoapOptionsBuilder::createSwaWithClassMapV11( SoapOptionsBuilder::createSwaWithClassMapV11(
@ -265,8 +275,6 @@ class SoapClientTest extends PHPUnit_Framework_TestCase
file_put_contents(self::CACHE_DIR . '/testSoapCallSwaWithAttachmentsOnResponse.xml', $soapResponse->getContent()); file_put_contents(self::CACHE_DIR . '/testSoapCallSwaWithAttachmentsOnResponse.xml', $soapResponse->getContent());
file_put_contents(self::CACHE_DIR . '/testSoapCallSwaWithAttachmentsOnResponse.txt', $firstAttachment->getContent()); file_put_contents(self::CACHE_DIR . '/testSoapCallSwaWithAttachmentsOnResponse.txt', $firstAttachment->getContent());
pclose($localWebServerProcess);
} }
public function removeOneTimeData($string) public function removeOneTimeData($string)

View File

@ -9,5 +9,5 @@ if (isset($_GET['wsdl'])) {
exit; exit;
} }
header('Content-type: text/xml'); header('Content-type: multipart/related; type="application/soap+xml"; charset=utf-8; boundary=Part_13_58e3bc35f3743.58e3bc35f376f; start="<part-424dbe68-e2da-450f-9a82-cc3e82742503@response.info>"');
echo file_get_contents(FIXTURES_DIR.'/Message/Response/soapCallWithSwaAttachmentsOnResponse.response.message'); echo file_get_contents(FIXTURES_DIR.'/Message/Response/soapCallWithSwaAttachmentsOnResponse.response.message');