Skip to content

Commit 9153fe2

Browse files
committed
Added after merge.
1 parent 707f1cd commit 9153fe2

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

app/code/Magento/Swatches/Test/Unit/Model/SwatchAttributesProviderTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class SwatchAttributesProviderTest extends \PHPUnit\Framework\TestCase
2727
*/
2828
private $swatchAttributeCodes;
2929

30+
/**
31+
* @var \Magento\Swatches\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $swatchHelper;
34+
3035
/**
3136
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
3237
*/
@@ -36,16 +41,24 @@ protected function setUp()
3641
{
3742
$this->typeConfigurable = $this->createPartialMock(
3843
Configurable::class,
39-
['getConfigurableAttributes', 'getCodes']
44+
['getConfigurableAttributes', 'getCodes', 'getProductAttribute']
4045
);
4146

4247
$this->swatchAttributeCodes = $this->createMock(SwatchAttributeCodes::class);
4348

4449
$this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getTypeId']);
4550

51+
// $this->swatchHelper = (new ObjectManager($this))
52+
// ->getObject(\Magento\Swatches\Helper\Data::class);
53+
$this->swatchHelper = $this->createPartialMock(
54+
\Magento\Swatches\Helper\Data::class,
55+
['isSwatchAttribute']
56+
);
57+
4658
$this->swatchAttributeProvider = (new ObjectManager($this))->getObject(SwatchAttributesProvider::class, [
47-
'typeConfigurable' => $this->typeConfigurable,
48-
'swatchAttributeCodes' => $this->swatchAttributeCodes,
59+
'typeConfigurable' => $this->typeConfigurable,
60+
'swatchAttributeCodes' => $this->swatchAttributeCodes,
61+
'swatchesHelper' => $this->swatchHelper
4962
]);
5063
}
5164

@@ -59,6 +72,11 @@ public function testProvide()
5972
\Magento\Framework\Interception\InterceptorInterface::class
6073
);
6174

75+
$attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
76+
->disableOriginalConstructor()
77+
->setMethods(['setStoreId', 'getData', 'setData', 'getSource', 'hasData'])
78+
->getMock();
79+
6280
$configAttributeMock = $this->createPartialMock(
6381
Configurable\Attribute::class,
6482
['getAttributeId', 'getProductAttribute']
@@ -69,7 +87,7 @@ public function testProvide()
6987

7088
$configAttributeMock
7189
->method('getProductAttribute')
72-
->willReturn($productAttributeMock);
90+
->willReturn($attributeMock);
7391

7492
$this->typeConfigurable
7593
->method('getConfigurableAttributes')
@@ -81,6 +99,11 @@ public function testProvide()
8199
->method('getCodes')
82100
->willReturn($swatchAttributes);
83101

102+
$this->swatchHelper
103+
->method('isSwatchAttribute')
104+
->with($configAttributeMock)
105+
->willReturn(true);
106+
84107
$expected = [1 => $productAttributeMock];
85108
$result = $this->swatchAttributeProvider->provide($this->productMock);
86109

0 commit comments

Comments
 (0)