From e58927469ce8da805d921e9e0adad2f65948e6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Bechyn=C4=9B?= Date: Tue, 6 Feb 2018 00:38:35 +0100 Subject: [PATCH] Run mock server in each SoapClient test case & unit test fixed --- tests/BeSimple/SoapClient/SoapClientTest.php | 18 +++++++++++++----- tests/SwaEndpoint.php | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/BeSimple/SoapClient/SoapClientTest.php b/tests/BeSimple/SoapClient/SoapClientTest.php index ce0c0e9..517dc07 100644 --- a/tests/BeSimple/SoapClient/SoapClientTest.php +++ b/tests/BeSimple/SoapClient/SoapClientTest.php @@ -16,12 +16,24 @@ class SoapClientTest extends PHPUnit_Framework_TestCase { const CACHE_DIR = __DIR__ . '/../../../cache'; 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_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_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() { $soapClient = $this->getSoapBuilder()->build( @@ -233,8 +245,6 @@ class SoapClientTest extends PHPUnit_Framework_TestCase */ public function testSoapCallSwaWithAttachmentsOnResponse() { - $localWebServerProcess = popen('php -S localhost:9000 > /dev/null 2>&1 &', 'r'); - $soapClient = $this->getSoapBuilder()->buildWithSoapHeader( SoapClientOptionsBuilder::createWithTracing(), 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.txt', $firstAttachment->getContent()); - - pclose($localWebServerProcess); } public function removeOneTimeData($string) diff --git a/tests/SwaEndpoint.php b/tests/SwaEndpoint.php index 1b61b17..e611564 100644 --- a/tests/SwaEndpoint.php +++ b/tests/SwaEndpoint.php @@ -9,5 +9,5 @@ if (isset($_GET['wsdl'])) { exit; } -header('Content-type: text/xml'); +header('Content-type: multipart/related; type="application/soap+xml"; charset=utf-8; boundary=Part_13_58e3bc35f3743.58e3bc35f376f; start=""'); echo file_get_contents(FIXTURES_DIR.'/Message/Response/soapCallWithSwaAttachmentsOnResponse.response.message');