46 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
48 $this->storeManagerMock = $this->createMock(\
Magento\Store\Model\StoreManagerInterface::class);
50 'storeManager' => $this->storeManagerMock,
52 $this->statusFactoryMock = $this->getMockBuilder(\
Magento\Sales\Model\
Order\StatusFactory::class)
53 ->disableOriginalConstructor()
54 ->setMethods([
'load',
'create'])
56 $this->orderStatusCollectionFactoryMock = $this->createPartialMock(
64 'orderStatusFactory' => $this->statusFactoryMock,
65 'orderStatusCollectionFactory' => $this->orderStatusCollectionFactoryMock
78 'status' =>
'canceled',
80 'visible_on_front' => 1,
85 'status' =>
'complete',
87 'visible_on_front' => 0,
92 'status' =>
'processing',
94 'visible_on_front' => 1,
99 'status' =>
'pending_payment',
101 'visible_on_front' => 0,
105 $expectedResult = [
'complete',
'pending_payment'];
107 $collectionMock = $this->createPartialMock(Collection::class, [
'create',
'joinStates']);
108 $this->orderStatusCollectionFactoryMock->expects($this->once())
110 ->will($this->returnValue($collectionMock));
111 $collectionMock->expects($this->once())
112 ->method(
'joinStates')
113 ->will($this->returnValue($statuses));
115 $result = $this->salesConfig->getInvisibleOnFrontStatuses();
116 $this->assertSame($expectedResult,
$result);
128 'state' =>
'processing',
129 'label' =>
'Suspected Fraud',
134 'status' =>
'processing',
135 'state' =>
'processing',
136 'label' =>
'Processing',
140 $collectionMock = $this->createPartialMock(Collection::class, [
'create',
'joinStates']);
141 $this->orderStatusCollectionFactoryMock->expects($this->once())
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());
161 public function testGetStatuses($state, $joinLabels, $collectionData, $expectedResult)
163 $collectionMock = $this->createPartialMock(
165 [
'create',
'joinStates',
'addStateFilter',
'orderByLabel']
167 $this->orderStatusCollectionFactoryMock->expects($this->any())
169 ->will($this->returnValue($collectionMock));
171 $collectionMock->expects($this->once())
172 ->method(
'addStateFilter')
173 ->will($this->returnSelf());
175 $collectionMock->expects($this->once())
176 ->method(
'orderByLabel')
177 ->will($this->returnValue($collectionData));
179 $collectionMock->expects($this->once())
180 ->method(
'joinStates')
181 ->will($this->returnValue($collectionData));
183 $this->statusFactoryMock->method(
'create')
186 $this->statusFactoryMock->method(
'load')
187 ->willReturn($this->orderStatusModel);
189 $storeMock = $this->createMock(\
Magento\Store\Api\
Data\StoreInterface::class);
190 $storeMock->method(
'getId')
193 $this->storeManagerMock->method(
'getStore')
194 ->with($this->anything())
195 ->willReturn($storeMock);
197 $this->orderStatusModel->setData(
'store_labels', [1 =>
'Pending label']);
199 $result = $this->salesConfig->getStateStatuses($state, $joinLabels);
200 $this->assertSame($expectedResult,
$result);
203 $this->assertSame(
$result, $this->salesConfig->getStateStatuses($state, $joinLabels));
214 'processing state' => [
215 'state' =>
'processing',
216 'joinLabels' =>
false,
217 'collectionData' => [
221 'state' =>
'processing',
222 'store_label' =>
'Suspected Fraud',
227 'status' =>
'processing',
228 'state' =>
'processing',
229 'store_label' =>
'Processing',
233 'expectedResult' => [
239 'state' =>
'pending',
240 'joinLabels' =>
true,
241 'collectionData' => [
244 'status' =>
'pending_status',
245 'state' =>
'pending',
246 'store_label' =>
'Pending label',
250 'expectedResult' => [
251 'pending_status' =>
'Pending label'
testGetStatuses($state, $joinLabels, $collectionData, $expectedResult)
$orderStatusCollectionFactoryMock
testGetStateLabelByStateAndStatus()
testGetInvisibleOnFrontStatuses()
getStatusesDataProvider()