8 use \Magento\Webapi\Model\Soap\Fault;
15 const WSDL_URL =
'http://host.com/?wsdl&services=customerV1';
38 $this->_requestMock = $this->createMock(\
Magento\Framework\
App\RequestInterface::class);
40 $details = [
'param1' =>
'value1',
'param2' => 2];
42 $webapiException = new \Magento\Framework\Webapi\Exception(
43 __(
'Soap fault reason.'),
48 $this->_soapServerMock = $this->getMockBuilder(
50 )->disableOriginalConstructor()->getMock();
51 $this->_soapServerMock->expects($this->any())->method(
'generateUri')->will($this->returnValue(self::WSDL_URL));
53 $this->_localeResolverMock = $this->getMockBuilder(
54 \
Magento\Framework\Locale\Resolver::class
55 )->disableOriginalConstructor()->getMock();
56 $this->_localeResolverMock->expects(
61 $this->returnValue(
'en_US')
64 $this->_appStateMock = $this->createMock(\
Magento\Framework\
App\State::class);
66 $this->_soapFault = new \Magento\Webapi\Model\Soap\Fault(
68 $this->_soapServerMock,
70 $this->_localeResolverMock,
78 unset($this->_soapFault);
79 unset($this->_requestMock);
85 $this->_appStateMock->expects($this->any())->method(
'getMode')->will($this->returnValue(
'production'));
86 $wsdlUrl = urlencode(self::WSDL_URL);
87 $expectedResult = <<<XML
88 <?xml version=
"1.0" encoding=
"utf-8" ?>
89 <env:Envelope xmlns:env=
"http://www.w3.org/2003/05/soap-envelope" xmlns:m=
"{$wsdlUrl}">
93 <env:Value>env:Receiver</env:Value>
96 <env:Text xml:lang=
"en">Soap fault reason.</env:Text>
101 <m:GenericFaultParameter>
102 <m:key>param1</m:key>
104 </m:GenericFaultParameter>
105 <m:GenericFaultParameter>
106 <m:key>param2</m:key>
108 </m:GenericFaultParameter>
117 $actualXml = $this->_soapFault->
toXml();
121 'Wrong SOAP fault message with default parameters.' 127 $this->_appStateMock->expects($this->any())->method(
'getMode')->will($this->returnValue(
'developer'));
128 $actualXml = $this->_soapFault->toXml();
129 $this->assertContains(
'<m:Trace>', $actualXml,
'Exception trace is not found in XML.');
140 $additionalParameters,
144 $actualResult = $this->_soapFault->getSoapFaultMessage($faultReason, $faultCode, $additionalParameters);
145 $wsdlUrl = urlencode(self::WSDL_URL);
147 $this->
_sanitizeXML(str_replace(
'{wsdl_url}', $wsdlUrl, $expectedResult)),
161 $expectedXmls = include
__DIR__ .
'/../../_files/soap_fault/soap_fault_expected_xmls.php';
165 'ArrayDataDetails' => [
171 'Invalid' =>
'This node should be skipped' 173 $expectedXmls[
'expectedResultArrayDataDetails'],
174 'SOAP fault message with associated array data details is invalid.',
176 'IndexArrayDetails' => [
179 [
'value1',
'value2'],
180 $expectedXmls[
'expectedResultIndexArrayDetails'],
181 'SOAP fault message with index array data details is invalid.',
183 'EmptyArrayDetails' => [
187 $expectedXmls[
'expectedResultEmptyArrayDetails'],
188 'SOAP fault message with empty array data details is invalid.',
193 (object)[
'key' =>
'value'],
194 $expectedXmls[
'expectedResultObjectDetails'],
195 'SOAP fault message with object data details is invalid.',
197 'ComplexDataDetails' => [
201 $expectedXmls[
'expectedResultComplexDataDetails'],
202 'SOAP fault message with complex data details is invalid.',
210 $details = [
'param1' =>
'value1',
'param2' => 2];
212 $webapiException = new \Magento\Framework\Webapi\Exception(
213 __(
'Soap fault reason.'),
218 $soapFault = new \Magento\Webapi\Model\Soap\Fault(
220 $this->_soapServerMock,
222 $this->_localeResolverMock,
225 $actualXml = $soapFault->toXml();
226 $wsdlUrl = urlencode(self::WSDL_URL);
227 $expectedXml = <<<FAULT_XML
228 <?xml version=
"1.0" encoding=
"utf-8" ?>
229 <env:Envelope xmlns:env=
"http://www.w3.org/2003/05/soap-envelope" xmlns:m=
"{$wsdlUrl}">
233 <env:Value>env:Receiver</env:Value>
236 <env:Text xml:lang=
"en">{
$message}</env:Text>
241 <m:GenericFaultParameter>
242 <m:key>param1</m:key>
244 </m:GenericFaultParameter>
245 <m:GenericFaultParameter>
246 <m:key>param2</m:key>
248 </m:GenericFaultParameter>
260 "Soap fault is invalid." 272 $dom = new \DOMDocument(1.0);
273 $dom->preserveWhiteSpace =
false;
274 $dom->formatOutput =
false;
276 $dom->loadXML($xmlString);
278 return $dom->saveXML();
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testToXmlDeveloperModeOff()
dataProviderForGetSoapFaultMessageTest()
testToXmlDeveloperModeOn()
const NODE_DETAIL_PARAMETERS
testGetSoapFaultMessage( $faultReason, $faultCode, $additionalParameters, $expectedResult, $assertMessage)