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