File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -300,4 +300,23 @@ protected function _getStatuses($visibility)
300
300
}
301
301
return $ this ->statuses [(bool ) $ visibility ];
302
302
}
303
+
304
+ /**
305
+ * Retrieve label by state and status
306
+ *
307
+ * @param string $state
308
+ * @param string $status
309
+ * @return \Magento\Framework\Phrase|string
310
+ * @since 100.2.0
311
+ */
312
+ public function getStateLabelByStateAndStatus ($ state , $ status )
313
+ {
314
+ foreach ($ this ->_getCollection () as $ item ) {
315
+ if ($ item ->getData ('state ' ) == $ state && $ item ->getData ('status ' ) == $ status ) {
316
+ $ label = $ item ->getData ('label ' );
317
+ return __ ($ label );
318
+ }
319
+ }
320
+ return $ state ;
321
+ }
303
322
}
Original file line number Diff line number Diff line change @@ -116,6 +116,38 @@ public function testGetInvisibleOnFrontStatuses()
116
116
$ this ->assertSame ($ expectedResult , $ result );
117
117
}
118
118
119
+ /**
120
+ * @return void
121
+ */
122
+ public function testGetStateLabelByStateAndStatus ()
123
+ {
124
+ $ statuses = [
125
+ new DataObject (
126
+ [
127
+ 'status ' => 'fraud ' ,
128
+ 'state ' => 'processing ' ,
129
+ 'label ' => 'Suspected Fraud ' ,
130
+ ]
131
+ ),
132
+ new DataObject (
133
+ [
134
+ 'status ' => 'processing ' ,
135
+ 'state ' => 'processing ' ,
136
+ 'label ' => 'Processing ' ,
137
+ ]
138
+ )
139
+ ];
140
+ $ collectionMock = $ this ->createPartialMock (Collection::class, ['create ' , 'joinStates ' ]);
141
+ $ this ->orderStatusCollectionFactoryMock ->expects ($ this ->once ())
142
+ ->method ('create ' )
143
+ ->will ($ this ->returnValue ($ collectionMock ));
144
+ $ collectionMock ->expects ($ this ->once ())
145
+ ->method ('joinStates ' )
146
+ ->will ($ this ->returnValue ($ statuses ));
147
+ $ result = $ this ->salesConfig ->getStateLabelByStateAndStatus ('processing ' , 'fraud ' );
148
+ $ this ->assertSame ('Suspected Fraud ' , $ result ->getText ());
149
+ }
150
+
119
151
/**
120
152
* Test get statuses
121
153
*
You can’t perform that action at this time.
0 commit comments