localWebServerProcess = popen('php -S localhost:8000 > /dev/null 2>&1 &', 'r');
}
public function tearDown()
{
pclose($this->localWebServerProcess);
}
public function testSoapCallSwaWithLargeSwaResponseWithSoapFault()
{
$soapClient = $this->getSoapBuilder()->buildWithSoapHeader(
SoapClientOptionsBuilder::createWithEndpointLocation(
self::TEST_HTTP_URL.'/SwaSenderSoapFaultEndpoint.php'
),
SoapOptionsBuilder::createSwaWithClassMap(
self::TEST_HTTP_URL.'/SwaSenderEndpoint.php?wsdl',
new ClassMap([
'GenerateTestRequest' => GenerateTestRequest::class,
]),
SoapOptions::SOAP_CACHE_TYPE_NONE
),
new SoapHeader('http://schema.testcase', 'SoapHeader', [
'user' => 'admin',
])
);
$this->setExpectedException(SoapFault::class);
try {
$soapClient->soapCall('dummyServiceMethodWithOutgoingLargeSwa', []);
} catch (SoapFault $e) {
self::assertInstanceOf(
SoapFaultWithTracingData::class,
$e
);
/** @var SoapFaultWithTracingData $e */
self::assertEquals(
'911',
$e->faultcode
);
self::assertContains(
'with HTTP response code 500 with Message: This is a dummy SoapFault. and Code: 911',
$e->getMessage()
);
self::assertContains(
'911',
$e->getSoapResponseTracingData()->getLastResponse()
);
self::assertContains(
'',
$e->getSoapResponseTracingData()->getLastRequest()
);
self::assertContains(
'Content-Type: application/soap+xml; charset=utf-8; action="DummyService.dummyServiceMethodWithOutgoingLargeSwa"',
$e->getSoapResponseTracingData()->getLastRequestHeaders()
);
throw $e;
}
self::fail('Expected SoapFault was not thrown');
}
public function testSoapCallSwaWithLargeSwaResponseWithNoResponseFromEndpoint()
{
$soapClient = $this->getSoapBuilder()->buildWithSoapHeader(
SoapClientOptionsBuilder::createWithEndpointLocation(
self::TEST_HTTP_URL.'/NoSuchEndpointExists'
),
SoapOptionsBuilder::createSwaWithClassMap(
self::TEST_HTTP_URL.'/SwaSenderEndpoint.php?wsdl',
new ClassMap([
'GenerateTestRequest' => GenerateTestRequest::class,
]),
SoapOptions::SOAP_CACHE_TYPE_NONE
),
new SoapHeader('http://schema.testcase', 'SoapHeader', [
'user' => 'admin',
])
);
$this->setExpectedException(SoapFault::class);
try {
$soapClient->soapCall('dummyServiceMethodWithOutgoingLargeSwa', []);
} catch (SoapFault $e) {
self::assertInstanceOf(
SoapFaultWithTracingData::class,
$e
);
/** @var SoapFaultWithTracingData $e */
self::assertEquals(
'be-http-404',
$e->faultcode
);
self::assertContains(
'with HTTP response code 404',
$e->getMessage()
);
self::assertContains(
'not found',
$e->getSoapResponseTracingData()->getLastResponse()
);
self::assertContains(
'404 Not Found',
$e->getSoapResponseTracingData()->getLastResponseHeaders()
);
self::assertContains(
'',
$e->getSoapResponseTracingData()->getLastRequest()
);
self::assertContains(
'Content-Type: application/soap+xml; charset=utf-8; action="DummyService.dummyServiceMethodWithOutgoingLargeSwa"',
$e->getSoapResponseTracingData()->getLastRequestHeaders()
);
throw $e;
}
self::fail('Expected SoapFault was not thrown');
}
public function testSoapCallSwaWithLargeSwaResponseWithNoResponseFromEndpointHost()
{
$soapClient = $this->getSoapBuilder()->buildWithSoapHeader(
SoapClientOptionsBuilder::createWithEndpointLocation(
self::TEST_HTTP_URL_INVALID.'/NoSuchEndpointExists'
),
SoapOptionsBuilder::createSwaWithClassMap(
self::TEST_HTTP_URL.'/SwaSenderEndpoint.php?wsdl',
new ClassMap([
'GenerateTestRequest' => GenerateTestRequest::class,
]),
SoapOptions::SOAP_CACHE_TYPE_NONE
),
new SoapHeader('http://schema.testcase', 'SoapHeader', [
'user' => 'admin',
])
);
$this->setExpectedException(SoapFault::class);
try {
$soapClient->soapCall('dummyServiceMethodWithOutgoingLargeSwa', []);
} catch (SoapFault $e) {
self::assertInstanceOf(
SoapFaultWithTracingData::class,
$e
);
/** @var SoapFaultWithTracingData $e */
self::assertEquals(
'be-http-0',
$e->faultcode
);
self::assertContains(
'Could not resolve host',
$e->getMessage()
);
self::assertNull(
$e->getSoapResponseTracingData()->getLastResponseHeaders()
);
self::assertNull(
$e->getSoapResponseTracingData()->getLastResponse()
);
self::assertContains(
'',
$e->getSoapResponseTracingData()->getLastRequest()
);
self::assertNull(
$e->getSoapResponseTracingData()->getLastRequestHeaders()
);
throw $e;
}
self::fail('Expected SoapFault was not thrown');
}
private function getSoapBuilder()
{
return new SoapClientBuilder();
}
public function getSoapServerBuilder()
{
return new SoapServerBuilder();
}
}