8
8
namespace Magento \AsynchronousOperations \Test \Unit \Model ;
9
9
10
10
use Magento \AsynchronousOperations \Api \Data \OperationExtensionInterfaceFactory ;
11
- use Magento \AsynchronousOperations \Model \BulkStatus ;
12
11
use Magento \AsynchronousOperations \Model \OperationRepository ;
13
12
use Magento \AsynchronousOperations \Model \ResourceModel \Operation \Collection as OperationCollection ;
14
13
use Magento \AsynchronousOperations \Model \ResourceModel \Operation \CollectionFactory as OperationCollectionFactory ;
15
14
use Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface ;
16
15
use Magento \Framework \Api \SearchCriteria \CollectionProcessorInterface ;
17
16
use Magento \Framework \EntityManager \EntityManager ;
18
17
use Magento \AsynchronousOperations \Api \Data \OperationSearchResultsInterfaceFactory as SearchResultFactory ;
18
+ use Magento \AsynchronousOperations \Api \Data \OperationSearchResultsInterface ;
19
+ use Magento \Framework \Api \SearchCriteriaInterface ;
19
20
use PHPUnit \Framework \MockObject \MockObject ;
20
21
use PHPUnit \Framework \TestCase ;
21
22
@@ -29,7 +30,7 @@ class OperationRepositoryTest extends TestCase
29
30
/**
30
31
* @var OperationRepository
31
32
*/
32
- private OperationRepository $ model ;
33
+ private $ model ;
33
34
34
35
/**
35
36
* @var EntityManager|MockObject
@@ -66,6 +67,66 @@ class OperationRepositoryTest extends TestCase
66
67
*/
67
68
private $ logger ;
68
69
70
+ /**
71
+ * private $item
72
+ */
73
+ private array $ items = [
74
+ "items " => [
75
+ [
76
+ "extension_attributes " => [
77
+ "start_time " => "2022-05-06 05:48:04 "
78
+ ],
79
+ "id " => 1 ,
80
+ "bulk_uuid " => "89300764-2502-44c6-a377-70b9565c34b8 " ,
81
+ "topic_name " => "async.magento.customer.api.accountmanagementinterface.createaccount.post " ,
82
+ "serialized_data " => "{ \"entity_id \":null, \"entity_link \": \"\", \"meta_information \": \"{ \\\"customer \\\":{ \\\"email \\\": \\\"mshaw@example.com \\\", \\\"firstname \\\": \\\"Melanie Shaw \\\", \\\"lastname \\\": \\\"Doe \\\"}, \\\"password \\\": \\\"Strong-Password \\\"} \"} " ,
83
+ "result_serialized_data " => null ,
84
+ "status " => 4 ,
85
+ "result_message " => null ,
86
+ "error_code " => null
87
+ ],
88
+ [
89
+ "extension_attributes " => [
90
+ "start_time " => "2022-05-06 05:48:04 "
91
+ ],
92
+ "id " => 2 ,
93
+ "bulk_uuid " => "89300764-2502-44c6-a377-70b9565c34b8 " ,
94
+ "topic_name " => "async.magento.customer.api.accountmanagementinterface.createaccount.post " ,
95
+ "serialized_data " => "{ \"entity_id \":null, \"entity_link \": \"\", \"meta_information \": \"{ \\\"customer \\\":{ \\\"email \\\": \\\"bmartin@example.com \\\", \\\"firstname \\\": \\\"Bryce \\\", \\\"lastname \\\": \\\"Martin \\\"}, \\\"password \\\": \\\"Strong-Password \\\"} \"} " ,
96
+ "result_serialized_data " => null ,
97
+ "status " => 4 ,
98
+ "result_message " => null ,
99
+ "error_code " => null
100
+ ],
101
+ [
102
+ "extension_attributes " => [
103
+ "start_time " => "2022-05-06 05:48:04 "
104
+ ],
105
+ "id " => 3 ,
106
+ "bulk_uuid " => "89300764-2502-44c6-a377-70b9565c34b8 " ,
107
+ "topic_name " => "async.magento.customer.api.accountmanagementinterface.createaccount.post " ,
108
+ "serialized_data " => "{ \"entity_id \":null, \"entity_link \": \"\", \"meta_information \": \"{ \\\"customer \\\":{ \\\"email \\\": \\\"bmartin@example.com \\\", \\\"firstname \\\": \\\"Bryce \\\", \\\"lastname \\\": \\\"Martin \\\"}, \\\"password \\\": \\\"Strong-Password \\\"} \"} " ,
109
+ "result_serialized_data " => null ,
110
+ "status " => 4 ,
111
+ "result_message " => null ,
112
+ "error_code " => null
113
+ ],
114
+ [
115
+ "extension_attributes " => [
116
+ "start_time " => "2022-05-06 05:48:04 "
117
+ ],
118
+ "id " => 4 ,
119
+ "bulk_uuid " => "89300764-2502-44c6-a377-70b9565c34b8 " ,
120
+ "topic_name " => "async.magento.customer.api.accountmanagementinterface.createaccount.post " ,
121
+ "serialized_data " => "{ \"entity_id \":null, \"entity_link \": \"\", \"meta_information \": \"{ \\\"customer \\\":{ \\\"email \\\": \\\"tgomez@example.com \\\", \\\"firstname \\\": \\\"Teresa \\\", \\\"lastname \\\": \\\"Gomez \\\"}, \\\"password \\\": \\\"Strong-Password \\\"} \"} " ,
122
+ "result_serialized_data " => null ,
123
+ "status " => 4 ,
124
+ "result_message " => null ,
125
+ "error_code " => null
126
+ ],
127
+ ],
128
+ ];
129
+
69
130
/**
70
131
* @inheritdoc
71
132
*/
@@ -91,22 +152,18 @@ protected function setUp(): void
91
152
}
92
153
93
154
/**
94
- * @param int|null $failureType
95
- * @param array $failureCodes
96
- *
97
155
* @return void
98
- * @dataProvider getFailedOperationsByBulkIdDataProvider
99
156
*/
100
- public function testGetFailedOperationsByBulkId (? int $ failureType , array $ failureCodes ): void
157
+ public function testGetFailedOperationsByBulkId (): void
101
158
{
102
- $ bulkUuid = 'bulk-1 ' ;
159
+ $ searchResultInterface = $ this ->createMock (OperationSearchResultsInterface::class);
160
+ $ searchCriteria = $ this ->createMock (SearchCriteriaInterface::class);
161
+ $ this ->searchResultFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ searchResultInterface );
103
162
$ operationCollection = $ this ->createMock (OperationCollection::class);
163
+
164
+ $ operationCollection ->expects ($ this ->once ())->method ('getItems ' )->willReturn ($ this ->items );
165
+ $ operationCollection ->expects ($ this ->exactly (3 ))->method ('addFieldToSelect ' )->willReturnSelf ();
104
166
$ this ->operationCollectionFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ operationCollection );
105
- $ operationCollection
106
- ->method ('addFieldToFilter ' )
107
- ->withConsecutive (['bulk_uuid ' , $ bulkUuid ], ['status ' , $ failureCodes ])
108
- ->willReturnOnConsecutiveCalls ($ operationCollection , $ operationCollection );
109
- $ operationCollection ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([$ this ->operationMock ]);
110
- $ this ->assertEquals ([$ this ->operationMock ], $ this ->model ->getFailedOperationsByBulkId ($ bulkUuid , $ failureType ));
167
+ $ this ->model ->getList ($ searchCriteria );
111
168
}
112
169
}
0 commit comments