32 'resourcePath' =>
'/V1/errortest/success',
41 $this->assertEquals(
'a good id',
$item[
'value'],
'Success case is correct');
48 'resourcePath' =>
'/V1/errortest/notfound',
57 WebapiException::HTTP_NOT_FOUND,
58 'Resource with ID "%1" not found.' 66 'resourcePath' =>
'/V1/errortest/unauthorized',
75 WebapiException::HTTP_UNAUTHORIZED,
76 "The consumer isn't authorized to access %1.",
85 'resourcePath' =>
'/V1/errortest/otherException',
95 $expectedMessage =
'Internal Error. Details are available in Magento log file. Report ID: webapi-XXX';
99 WebapiException::HTTP_INTERNAL_ERROR,
102 'Magento\TestModule3\Service\V1\Error->otherException()' 126 }
catch (\Exception $e) {
127 $this->assertEquals($httpStatus, $e->getCode(),
'Checking HTTP status code');
129 $body = json_decode($e->getMessage(),
true);
131 $errorMessages = is_array($errorMessage) ? $errorMessage : [$errorMessage];
132 $actualMessage = $body[
'message'];
135 if (preg_match(
'/.*Report\sID\:\s([a-zA-Z0-9\-]*)/', $actualMessage, $matches)) {
136 $actualMessage = str_replace($matches[1],
'webapi-XXX', $actualMessage);
140 if (count($matches) > 1) {
141 $this->assertTrue(!empty($matches[1]),
'Report id missing for internal error.');
143 $this->assertContains(
146 "Message is invalid. Actual: '{$actualMessage}'. Expected one of: {'" . implode(
153 $this->assertEquals($parameters, $body[
'parameters'],
'Checking body parameters');
156 if ($this->mode == \
Magento\Framework\
App\State::MODE_DEVELOPER && $traceString) {
_markTestAsRestOnly($message=null)
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
_errorTest( $serviceInfo, $data, $httpStatus, $errorMessage, $parameters=[], $traceString=null)
static getObjectManager()