Skip to content

Commit 1a339cc

Browse files
committed
ACP2E-55: Simple only global attributes make configurable attributes hidden when creating product configurations
- Fixed the CR comments.
1 parent ecced32 commit 1a339cc

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/AttributesTest.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
namespace Magento\ConfigurableProduct\Test\Unit\Ui\DataProvider;
99

10+
use Magento\Catalog\Model\Product\Type;
1011
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
1112
use Magento\ConfigurableProduct\Model\ConfigurableAttributeHandler;
13+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1214
use Magento\ConfigurableProduct\Ui\DataProvider\Attributes;
1315
use Magento\Framework\DataObject;
1416
use Magento\Framework\DB\Select;
15-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1617
use PHPUnit\Framework\TestCase;
1718

1819
class AttributesTest extends TestCase
@@ -37,7 +38,6 @@ class AttributesTest extends TestCase
3738
*/
3839
protected function setUp(): void
3940
{
40-
$objectManager = new ObjectManager($this);
4141
$this->collectionMock = $this->getMockBuilder(Collection::class)
4242
->disableOriginalConstructor()
4343
->getMock();
@@ -52,14 +52,11 @@ protected function setUp(): void
5252
$collectionAttributeHandlerMock->expects($this->once())
5353
->method('getApplicableAttributes')
5454
->willReturn($this->collectionMock);
55-
$this->attributes = $objectManager->getObject(
56-
Attributes::class,
57-
[
58-
'name' => 'myName',
59-
'primaryFieldName' => 'myPrimaryFieldName',
60-
'requestFieldName' => 'myRequestFieldName',
61-
'configurableAttributeHandler' => $collectionAttributeHandlerMock
62-
]
55+
$this->attributes = new Attributes(
56+
'myName',
57+
'myPrimaryFieldName',
58+
'myRequestFieldName',
59+
$collectionAttributeHandlerMock
6360
);
6461
}
6562

@@ -77,6 +74,24 @@ public function testGetData()
7774
$this->collectionMock->expects($this->once())
7875
->method('getSelect')
7976
->willReturn($this->selectMock);
77+
$this->selectMock->expects($this->once())
78+
->method('where')
79+
->with('(`apply_to` IS NULL) OR
80+
(
81+
FIND_IN_SET(' .
82+
sprintf("'%s'", Type::TYPE_SIMPLE) . ',
83+
`apply_to`
84+
) AND
85+
FIND_IN_SET(' .
86+
sprintf("'%s'", Type::TYPE_VIRTUAL) . ',
87+
`apply_to`
88+
) AND
89+
FIND_IN_SET(' .
90+
sprintf("'%s'", Configurable::TYPE_CODE) . ',
91+
`apply_to`
92+
)
93+
)')
94+
->willReturnSelf();
8095
$this->collectionMock->expects($this->once())
8196
->method('getItems')
8297
->willReturn([new DataObject(['attribute' => 'color'])]);

0 commit comments

Comments
 (0)