GettersTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Webapi\Routing;
  7. use Magento\TestModule5\Service\V1\Entity\AllSoapAndRest;
  8. class GettersTest extends \Magento\Webapi\Routing\BaseService
  9. {
  10. /**
  11. * @var string
  12. */
  13. protected $_version;
  14. /**
  15. * @var string
  16. */
  17. protected $_restResourcePath;
  18. /**
  19. * @var string
  20. */
  21. protected $_soapService = 'testModule5AllSoapAndRest';
  22. protected function setUp()
  23. {
  24. $this->_version = 'V1';
  25. $this->_soapService = "testModule5AllSoapAndRest{$this->_version}";
  26. $this->_restResourcePath = "/{$this->_version}/TestModule5/";
  27. }
  28. public function testGetters()
  29. {
  30. $itemId = 1;
  31. $serviceInfo = [
  32. 'rest' => [
  33. 'resourcePath' => $this->_restResourcePath . $itemId,
  34. 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
  35. ],
  36. 'soap' => [
  37. 'service' => $this->_soapService,
  38. 'operation' => $this->_soapService . 'Item',
  39. ],
  40. ];
  41. $requestData = [AllSoapAndRest::ID => $itemId];
  42. $item = $this->_webApiCall($serviceInfo, $requestData);
  43. $this->assertEquals($itemId, $item[AllSoapAndRest::ID], 'Item was retrieved unsuccessfully');
  44. $isEnabled = isset($item[AllSoapAndRest::ENABLED]) && $item[AllSoapAndRest::ENABLED] === true;
  45. $this->assertTrue($isEnabled, 'Getter with "is" prefix is processed incorrectly.');
  46. $hasOrder = isset($item[AllSoapAndRest::HAS_ORDERS]) && $item[AllSoapAndRest::HAS_ORDERS] === true;
  47. $this->assertTrue($hasOrder, 'Getter with "has" prefix is processed incorrectly.');
  48. }
  49. }