77
88namespace Magento \ConfigurableProduct \Test \Unit \Ui \DataProvider ;
99
10+ use Magento \Catalog \Model \Product \Type ;
1011use Magento \Catalog \Model \ResourceModel \Product \Attribute \Collection ;
1112use Magento \ConfigurableProduct \Model \ConfigurableAttributeHandler ;
13+ use Magento \ConfigurableProduct \Model \Product \Type \Configurable ;
1214use Magento \ConfigurableProduct \Ui \DataProvider \Attributes ;
1315use Magento \Framework \DataObject ;
1416use Magento \Framework \DB \Select ;
15- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
1617use PHPUnit \Framework \TestCase ;
1718
1819class 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