7
7
8
8
namespace Magento \ConfigurableProduct \Test \Unit \Ui \DataProvider ;
9
9
10
+ use Magento \Catalog \Model \Product \Type ;
10
11
use Magento \Catalog \Model \ResourceModel \Product \Attribute \Collection ;
11
12
use Magento \ConfigurableProduct \Model \ConfigurableAttributeHandler ;
13
+ use Magento \ConfigurableProduct \Model \Product \Type \Configurable ;
12
14
use Magento \ConfigurableProduct \Ui \DataProvider \Attributes ;
13
15
use Magento \Framework \DataObject ;
14
16
use Magento \Framework \DB \Select ;
15
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
16
17
use PHPUnit \Framework \TestCase ;
17
18
18
19
class AttributesTest extends TestCase
@@ -37,7 +38,6 @@ class AttributesTest extends TestCase
37
38
*/
38
39
protected function setUp (): void
39
40
{
40
- $ objectManager = new ObjectManager ($ this );
41
41
$ this ->collectionMock = $ this ->getMockBuilder (Collection::class)
42
42
->disableOriginalConstructor ()
43
43
->getMock ();
@@ -52,14 +52,11 @@ protected function setUp(): void
52
52
$ collectionAttributeHandlerMock ->expects ($ this ->once ())
53
53
->method ('getApplicableAttributes ' )
54
54
->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
63
60
);
64
61
}
65
62
@@ -77,6 +74,24 @@ public function testGetData()
77
74
$ this ->collectionMock ->expects ($ this ->once ())
78
75
->method ('getSelect ' )
79
76
->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 ();
80
95
$ this ->collectionMock ->expects ($ this ->once ())
81
96
->method ('getItems ' )
82
97
->willReturn ([new DataObject (['attribute ' => 'color ' ])]);
0 commit comments