OperationRepositoryInterfaceTest.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AsynchronousOperations\Api;
  8. use Magento\Framework\Webapi\Rest\Request;
  9. use Magento\TestFramework\TestCase\WebapiAbstract;
  10. use Magento\Framework\Bulk\OperationInterface;
  11. class OperationRepositoryInterfaceTest extends WebapiAbstract
  12. {
  13. const RESOURCE_PATH = '/V1/bulk';
  14. const SERVICE_NAME = 'asynchronousOperationsOperationRepositoryV1';
  15. /**
  16. * @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
  17. */
  18. public function testGetListByBulkStartTime()
  19. {
  20. $searchCriteria = [
  21. 'searchCriteria' => [
  22. 'filter_groups' => [
  23. [
  24. 'filters' => [
  25. [
  26. 'field' => 'start_time',
  27. 'value' => '2010-10-10 00:00:00',
  28. 'condition_type' => 'lteq',
  29. ],
  30. ],
  31. ],
  32. ],
  33. 'current_page' => 1,
  34. ],
  35. ];
  36. $serviceInfo = [
  37. 'rest' => [
  38. 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($searchCriteria),
  39. 'httpMethod' => Request::HTTP_METHOD_GET,
  40. ],
  41. 'soap' => [
  42. 'service' => self::SERVICE_NAME,
  43. 'operation' => self::SERVICE_NAME . 'GetList',
  44. ],
  45. ];
  46. $response = $this->_webApiCall($serviceInfo, $searchCriteria);
  47. $this->assertArrayHasKey('search_criteria', $response);
  48. $this->assertArrayHasKey('total_count', $response);
  49. $this->assertArrayHasKey('items', $response);
  50. $this->assertEquals($searchCriteria['searchCriteria'], $response['search_criteria']);
  51. $this->assertEquals(3, $response['total_count']);
  52. $this->assertEquals(3, count($response['items']));
  53. foreach ($response['items'] as $item) {
  54. $this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);
  55. }
  56. }
  57. /**
  58. * @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
  59. */
  60. public function testGetList()
  61. {
  62. $searchCriteria = [
  63. 'searchCriteria' => [
  64. 'filter_groups' => [
  65. [
  66. 'filters' => [
  67. [
  68. 'field' => 'bulk_uuid',
  69. 'value' => 'bulk-uuid-searchable-6',
  70. 'condition_type' => 'eq',
  71. ],
  72. ],
  73. ],
  74. [
  75. 'filters' => [
  76. [
  77. 'field' => 'status',
  78. 'value' => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
  79. 'condition_type' => 'eq',
  80. ],
  81. ],
  82. ],
  83. ],
  84. 'current_page' => 1,
  85. ],
  86. ];
  87. $serviceInfo = [
  88. 'rest' => [
  89. 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($searchCriteria),
  90. 'httpMethod' => Request::HTTP_METHOD_GET,
  91. ],
  92. 'soap' => [
  93. 'service' => self::SERVICE_NAME,
  94. 'operation' => self::SERVICE_NAME . 'GetList',
  95. ],
  96. ];
  97. $response = $this->_webApiCall($serviceInfo, $searchCriteria);
  98. $this->assertArrayHasKey('search_criteria', $response);
  99. $this->assertArrayHasKey('total_count', $response);
  100. $this->assertArrayHasKey('items', $response);
  101. $this->assertEquals($searchCriteria['searchCriteria'], $response['search_criteria']);
  102. $this->assertEquals(1, $response['total_count']);
  103. $this->assertEquals(1, count($response['items']));
  104. foreach ($response['items'] as $item) {
  105. $this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);
  106. }
  107. }
  108. }