Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PreventAssignedToSalesChannelsStockDeletingTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
15 {
21  public function testCouldNotDeleteException()
22  {
23  $stockId = 10;
24  $serviceInfo = [
25  'rest' => [
26  'resourcePath' => '/V1/inventory/stocks/' . $stockId,
27  'httpMethod' => Request::HTTP_METHOD_DELETE,
28  ],
29  'soap' => [
30  'service' => 'inventoryApiStockRepositoryV1',
31  'operation' => 'inventoryApiStockRepositoryV1DeleteById',
32  ],
33  ];
34  $expectedMessage = 'Stock has at least one sale channel and could not be deleted.';
35  try {
36  (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST)
37  ? $this->_webApiCall($serviceInfo)
38  : $this->_webApiCall($serviceInfo, ['stockId' => $stockId]);
39  $this->fail('Expected throwing exception');
40  } catch (\Exception $e) {
41  if (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST) {
42  $errorData = $this->processRestExceptionResult($e);
43  self::assertEquals($expectedMessage, $errorData['message']);
44  self::assertEquals(Exception::HTTP_BAD_REQUEST, $e->getCode());
45  } elseif (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) {
46  $this->assertInstanceOf('SoapFault', $e);
47  $this->checkSoapFault($e, $expectedMessage, 'env:Sender');
48  } else {
49  throw $e;
50  }
51  }
52  }
53 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
checkSoapFault( $soapFault, $expectedMessage, $expectedFaultCode, $expectedErrorParams=[], $expectedWrappedErrors=[], $traceString=null)