Skip to content

Commit 2d4b68b

Browse files
committed
MAGETWO-97044: Calculated Labels in Columns Widget
1 parent 072b863 commit 2d4b68b

File tree

1 file changed

+38
-1
lines changed
  • app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier

1 file changed

+38
-1
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface;
1010
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
11+
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
1112
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
1213
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
1314
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory;
@@ -254,7 +255,15 @@ protected function setUp()
254255
$this->searchResultsMock = $this->getMockBuilder(SearchResultsInterface::class)
255256
->getMockForAbstractClass();
256257
$this->eavAttributeMock = $this->getMockBuilder(Attribute::class)
257-
->setMethods(['load', 'getAttributeGroupCode', 'getApplyTo', 'getFrontendInput', 'getAttributeCode'])
258+
->setMethods([
259+
'load',
260+
'getAttributeGroupCode',
261+
'getApplyTo',
262+
'getFrontendInput',
263+
'getAttributeCode',
264+
'usesSource',
265+
'getSource',
266+
])
258267
->disableOriginalConstructor()
259268
->getMock();
260269
$this->productAttributeMock = $this->getMockBuilder(ProductAttributeInterface::class)
@@ -460,6 +469,20 @@ public function testSetupAttributeMetaDefaultAttribute($productId, array $attrib
460469
$configPath = 'arguments/data/config';
461470
$groupCode = 'product-details';
462471
$sortOrder = '0';
472+
$attributeOptions = [
473+
['value' => 1, 'label' => 'Int label'],
474+
['value' => 1.5, 'label' => 'Float label'],
475+
['value' => true, 'label' => 'Boolean label'],
476+
['value' => 'string', 'label' => 'String label'],
477+
['value' => ['test1', 'test2'], 'label' => 'Array label'],
478+
];
479+
$attributeOptionsExpected = [
480+
['value' => '1', 'label' => 'Int label', '__disableTmpl' => true],
481+
['value' => '1.5', 'label' => 'Float label', '__disableTmpl' => true],
482+
['value' => '1', 'label' => 'Boolean label', '__disableTmpl' => true],
483+
['value' => 'string', 'label' => 'String label', '__disableTmpl' => true],
484+
['value' => ['test1', 'test2'], 'label' => 'Array label', '__disableTmpl' => true],
485+
];
463486

464487
$this->productMock->expects($this->any())
465488
->method('getId')
@@ -491,6 +514,11 @@ public function testSetupAttributeMetaDefaultAttribute($productId, array $attrib
491514
->method('getCustomAttribute')
492515
->willReturn($attributeMock);
493516

517+
$this->eavAttributeMock->method('usesSource')->willReturn(true);
518+
$attributeSource = $this->getMockBuilder(SourceInterface::class)->getMockForAbstractClass();
519+
$attributeSource->method('getAllOptions')->willReturn($attributeOptions);
520+
$this->eavAttributeMock->method('getSource')->willReturn($attributeSource);
521+
494522
$this->arrayManagerMock->expects($this->any())
495523
->method('set')
496524
->with(
@@ -502,6 +530,15 @@ public function testSetupAttributeMetaDefaultAttribute($productId, array $attrib
502530

503531
$this->arrayManagerMock->expects($this->any())
504532
->method('merge')
533+
->with(
534+
$this->anything(),
535+
$this->anything(),
536+
$this->callback(
537+
function ($value) use ($attributeOptionsExpected) {
538+
return isset($value['options']) ? $value['options'] === $attributeOptionsExpected : true;
539+
}
540+
)
541+
)
505542
->willReturn($expected);
506543

507544
$this->arrayManagerMock->expects($this->any())

0 commit comments

Comments
 (0)