Skip to content

Commit 9a853ef

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-96949' into 2.1.18-develop-pr66
2 parents 050d276 + 18b9bf5 commit 9a853ef

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Sales\Ui\Component\Listing\Column\Status\Options;
1111

1212
/**
13-
* Class OptionsTest
13+
* Class OptionsTest for Magento\Sales\Ui\Component\Listing\Column\Status\Options.
1414
*/
1515
class OptionsTest extends \PHPUnit_Framework_TestCase
1616
{
@@ -24,35 +24,62 @@ class OptionsTest extends \PHPUnit_Framework_TestCase
2424
*/
2525
protected $collectionFactoryMock;
2626

27+
/**
28+
* @inheritdoc
29+
*/
2730
protected function setUp()
2831
{
2932
$objectManager = new ObjectManager($this);
3033
$this->collectionFactoryMock = $this->getMock(
31-
'Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory',
34+
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class,
3235
['create'],
3336
[],
3437
'',
3538
false
3639
);
3740
$this->model = $objectManager->getObject(
38-
'Magento\Sales\Ui\Component\Listing\Column\Status\Options',
41+
\Magento\Sales\Ui\Component\Listing\Column\Status\Options::class,
3942
['collectionFactory' => $this->collectionFactoryMock]
4043
);
4144
}
4245

46+
/**
47+
* Unit test for toOptionArray method.
48+
*
49+
* @return void
50+
*/
4351
public function testToOptionArray()
4452
{
45-
$collectionMock =
46-
$this->getMock('Magento\Sales\Model\ResourceModel\Order\Status\Collection', [], [], '', false);
47-
$options = ['options'];
53+
$collectionMock = $this->getMock(
54+
\Magento\Sales\Model\ResourceModel\Order\Status\Collection::class,
55+
[],
56+
[],
57+
'',
58+
false
59+
);
60+
61+
$options = [
62+
[
63+
'value' => '1',
64+
'label' => 'Label',
65+
],
66+
];
67+
68+
$expectedOptions = [
69+
[
70+
'value' => '1',
71+
'label' => 'Label',
72+
'__disableTmpl' => true,
73+
],
74+
];
4875

4976
$this->collectionFactoryMock->expects($this->once())
5077
->method('create')
5178
->willReturn($collectionMock);
5279
$collectionMock->expects($this->once())
5380
->method('toOptionArray')
5481
->willReturn($options);
55-
$this->assertEquals($options, $this->model->toOptionArray());
56-
$this->assertEquals($options, $this->model->toOptionArray());
82+
83+
$this->assertEquals($expectedOptions, $this->model->toOptionArray());
5784
}
5885
}

app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Ui\Component\Listing\Column\Status;
78

89
use Magento\Framework\Data\OptionSourceInterface;
910
use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory;
1011

1112
/**
12-
* Class Options
13+
* Class to transform Status options into a form of value-label pairs.
1314
*/
1415
class Options implements OptionSourceInterface
1516
{
@@ -24,8 +25,6 @@ class Options implements OptionSourceInterface
2425
protected $collectionFactory;
2526

2627
/**
27-
* Constructor
28-
*
2928
* @param CollectionFactory $collectionFactory
3029
*/
3130
public function __construct(CollectionFactory $collectionFactory)
@@ -34,15 +33,22 @@ public function __construct(CollectionFactory $collectionFactory)
3433
}
3534

3635
/**
37-
* Get options
36+
* Get options into array.
3837
*
3938
* @return array
4039
*/
4140
public function toOptionArray()
4241
{
4342
if ($this->options === null) {
44-
$this->options = $this->collectionFactory->create()->toOptionArray();
43+
$options = $this->collectionFactory->create()->toOptionArray();
44+
45+
array_walk($options, function (&$option) {
46+
$option['__disableTmpl'] = true;
47+
});
48+
49+
$this->options = $options;
4550
}
51+
4652
return $this->options;
4753
}
4854
}

0 commit comments

Comments
 (0)