Skip to content

Commit 3e7814a

Browse files
author
Vasiliev.A
committed
add misisng strict declaration, fix tests data fixture, fix test
1 parent 8306c69 commit 3e7814a

File tree

4 files changed

+75
-48
lines changed

4 files changed

+75
-48
lines changed

app/code/Magento/AsynchronousOperations/Model/OperationRepository.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
101101
$collection = $this->collectionFactory->create();
102102
$this->joinProcessor->process($collection, \Magento\AsynchronousOperations\Api\Data\OperationInterface::class);
103103
$this->collectionProcessor->process($searchCriteria, $collection);
104-
105104
$searchResult->setSearchCriteria($searchCriteria);
106105
$searchResult->setTotalCount($collection->getSize());
107106

108107
$items = [];
109-
110108
foreach ($collection->getItems() as $item) {
111109
$extensionAttributes = $item->getExtensionAttributes();
112110
if ($extensionAttributes == null) {
@@ -116,10 +114,8 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
116114
$item->setExtensionAttributes($extensionAttributes);
117115
$items[] = $item;
118116
}
119-
120117
$searchResult->setItems($items);
121118

122-
123119
return $searchResult;
124120
}
125121
}

dev/tests/api-functional/testsuite/Magento/AsynchronousOperations/Api/OperationRepositoryInterfaceTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\AsynchronousOperations\Api;
810

911
use Magento\Framework\Webapi\Rest\Request;
@@ -16,7 +18,7 @@ class OperationRepositoryInterfaceTest extends WebapiAbstract
1618
const SERVICE_NAME = 'asynchronousOperationsOperationRepositoryV1';
1719

1820
/**
19-
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/bulk.php
21+
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
2022
*/
2123
public function testGetListByBulkStartTime()
2224
{
@@ -59,12 +61,12 @@ public function testGetListByBulkStartTime()
5961
$this->assertEquals(3, count($response['items']));
6062

6163
foreach ($response['items'] as $item) {
62-
$this->assertEquals('bulk-uuid-6', $item['bulk_uuid']);
64+
$this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);
6365
}
6466
}
6567

6668
/**
67-
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/bulk.php
69+
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
6870
*/
6971
public function testGetList()
7072
{
@@ -75,7 +77,7 @@ public function testGetList()
7577
'filters' => [
7678
[
7779
'field' => 'bulk_uuid',
78-
'value' => 'bulk-uuid-6',
80+
'value' => 'bulk-uuid-searchable-6',
7981
'condition_type' => 'eq',
8082
],
8183
],
@@ -116,7 +118,7 @@ public function testGetList()
116118
$this->assertEquals(1, count($response['items']));
117119

118120
foreach ($response['items'] as $item) {
119-
$this->assertEquals('bulk-uuid-6', $item['bulk_uuid']);
121+
$this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);
120122
}
121123
}
122124
}

dev/tests/integration/testsuite/Magento/AsynchronousOperations/_files/bulk.php

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,31 @@
2020
'user_id' => 1,
2121
'description' => 'Bulk Description',
2222
'operation_count' => 1,
23-
'start_time' => null,
2423
],
2524
'in_progress_success' => [
2625
'uuid' => 'bulk-uuid-2',
2726
'user_id' => 1,
2827
'description' => 'Bulk Description',
2928
'operation_count' => 3,
30-
'start_time' => null,
3129
],
3230
'in_progress_failed' => [
3331
'uuid' => 'bulk-uuid-3',
3432
'user_id' => 1,
3533
'description' => 'Bulk Description',
3634
'operation_count' => 2,
37-
'start_time' => null,
3835
],
3936
'finish_success' => [
4037
'uuid' => 'bulk-uuid-4',
4138
'user_id' => 1,
4239
'description' => 'Bulk Description',
4340
'operation_count' => 1,
44-
'start_time' => null,
4541
],
4642
'finish_failed' => [
4743
'uuid' => 'bulk-uuid-5',
4844
'user_id' => 1,
4945
'description' => 'Bulk Description',
5046
'operation_count' => 2,
51-
'start_time' => null,
5247
],
53-
'started_searchable' => [
54-
'uuid' => 'bulk-uuid-6',
55-
'user_id' => 1,
56-
'description' => 'Bulk Description',
57-
'operation_count' => 3,
58-
'start_time' => '2009-10-10 00:00:00'
59-
]
6048
];
6149
// Only processed operations are saved into database (i.e. operations that are not in 'open' state)
6250
$operations = [
@@ -100,35 +88,10 @@
10088
'error_code' => 2222,
10189
'result_message' => 'Entity with ID=4 does not exist',
10290
],
103-
[
104-
'bulk_uuid' => 'bulk-uuid-6',
105-
'topic_name' => 'topic-5',
106-
'serialized_data' => json_encode(['entity_id' => 5]),
107-
'status' => OperationInterface::STATUS_TYPE_COMPLETE,
108-
'error_code' => null,
109-
'result_message' => null,
110-
],
111-
[
112-
'bulk_uuid' => 'bulk-uuid-6',
113-
'topic_name' => 'topic-5',
114-
'serialized_data' => json_encode(['entity_id' => 5, 'meta_information' => 'Test']),
115-
'status' => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
116-
'error_code' => 1111,
117-
'result_message' => 'Something went wrong during your request',
118-
],
119-
[
120-
'bulk_uuid' => 'bulk-uuid-6',
121-
'topic_name' => 'topic-5',
122-
'serialized_data' => json_encode(['entity_id' => 5]),
123-
'status' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED,
124-
'error_code' => 2222,
125-
'result_message' => 'Entity with ID=4 does not exist',
126-
],
127-
12891
];
12992

130-
$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `description`, `operation_count`, `start_time`)"
131-
. " VALUES (:uuid, :user_id, :description, :operation_count, :start_time);";
93+
$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `description`, `operation_count`)"
94+
. " VALUES (:uuid, :user_id, :description, :operation_count);";
13295
foreach ($bulks as $bulk) {
13396
$connection->query($bulkQuery, $bulk);
13497
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\TestFramework\Helper\Bootstrap;
7+
use Magento\Framework\Bulk\OperationInterface;
8+
9+
/**
10+
* @var $resource Magento\Framework\App\ResourceConnection
11+
*/
12+
$resource = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ResourceConnection::class);
13+
$connection = $resource->getConnection();
14+
$bulkTable = $resource->getTableName('magento_bulk');
15+
$operationTable = $resource->getTableName('magento_operation');
16+
17+
$bulks = [
18+
'started_searchable' => [
19+
'uuid' => 'bulk-uuid-searchable-6',
20+
'user_id' => 1,
21+
'description' => 'Bulk Description',
22+
'operation_count' => 3,
23+
'start_time' => '2009-10-10 00:00:00'
24+
]
25+
];
26+
// Only processed operations are saved into database (i.e. operations that are not in 'open' state)
27+
$operations = [
28+
[
29+
'bulk_uuid' => 'bulk-uuid-searchable-6',
30+
'topic_name' => 'topic-5',
31+
'serialized_data' => json_encode(['entity_id' => 5]),
32+
'status' => OperationInterface::STATUS_TYPE_COMPLETE,
33+
'error_code' => null,
34+
'result_message' => null,
35+
],
36+
[
37+
'bulk_uuid' => 'bulk-uuid-searchable-6',
38+
'topic_name' => 'topic-5',
39+
'serialized_data' => json_encode(['entity_id' => 5, 'meta_information' => 'Test']),
40+
'status' => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
41+
'error_code' => 1111,
42+
'result_message' => 'Something went wrong during your request',
43+
],
44+
[
45+
'bulk_uuid' => 'bulk-uuid-searchable-6',
46+
'topic_name' => 'topic-5',
47+
'serialized_data' => json_encode(['entity_id' => 5]),
48+
'status' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED,
49+
'error_code' => 2222,
50+
'result_message' => 'Entity with ID=4 does not exist',
51+
],
52+
53+
];
54+
55+
$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `description`, `operation_count`, `start_time`)"
56+
. " VALUES (:uuid, :user_id, :description, :operation_count, :start_time);";
57+
foreach ($bulks as $bulk) {
58+
$connection->query($bulkQuery, $bulk);
59+
}
60+
61+
$operationQuery = "INSERT INTO {$operationTable}"
62+
. " (`bulk_uuid`, `topic_name`, `serialized_data`, `status`, `error_code`, `result_message`)"
63+
. " VALUES (:bulk_uuid, :topic_name, :serialized_data, :status, :error_code, :result_message);";
64+
foreach ($operations as $operation) {
65+
$connection->query($operationQuery, $operation);
66+
}

0 commit comments

Comments
 (0)