@@ -12,7 +12,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase
12
12
/**
13
13
* @var \Magento\CatalogWidget\Model\Rule\Condition\Product
14
14
*/
15
- protected $ object ;
15
+ protected $ conditionProduct ;
16
16
17
17
/**
18
18
* @var \Magento\Framework\ObjectManager
@@ -23,16 +23,14 @@ protected function setUp()
23
23
{
24
24
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
25
25
$ rule = $ this ->objectManager ->create ('Magento\CatalogWidget\Model\Rule ' );
26
- $ this ->object = $ this ->objectManager ->create (
27
- 'Magento\CatalogWidget\Model\Rule\Condition\Product '
28
- );
29
- $ this ->object ->setRule ($ rule );
26
+ $ this ->conditionProduct = $ this ->objectManager ->create ('Magento\CatalogWidget\Model\Rule\Condition\Product ' );
27
+ $ this ->conditionProduct ->setRule ($ rule );
30
28
}
31
29
32
30
public function testLoadAttributeOptions ()
33
31
{
34
- $ this ->object ->loadAttributeOptions ();
35
- $ options = $ this ->object ->getAttributeOption ();
32
+ $ this ->conditionProduct ->loadAttributeOptions ();
33
+ $ options = $ this ->conditionProduct ->getAttributeOption ();
36
34
$ this ->assertArrayHasKey ('sku ' , $ options );
37
35
$ this ->assertArrayHasKey ('attribute_set_id ' , $ options );
38
36
$ this ->assertArrayHasKey ('category_ids ' , $ options );
@@ -45,29 +43,29 @@ public function testLoadAttributeOptions()
45
43
public function testAddGlobalAttributeToCollection ()
46
44
{
47
45
$ collection = $ this ->objectManager ->create ('Magento\Catalog\Model\Resource\Product\Collection ' );
48
- $ this ->object ->setAttribute ('special_price ' );
49
- $ this ->object ->addToCollection ($ collection );
50
- $ collectedAttributes = $ this ->object ->getRule ()->getCollectedAttributes ();
46
+ $ this ->conditionProduct ->setAttribute ('special_price ' );
47
+ $ this ->conditionProduct ->addToCollection ($ collection );
48
+ $ collectedAttributes = $ this ->conditionProduct ->getRule ()->getCollectedAttributes ();
51
49
$ this ->assertArrayHasKey ('special_price ' , $ collectedAttributes );
52
50
$ query = (string )$ collection ->getSelect ();
53
51
$ this ->assertContains ('special_price ' , $ query );
54
- $ this ->assertEquals ('at_special_price.value ' , $ this ->object ->getMappedSqlField ());
52
+ $ this ->assertEquals ('at_special_price.value ' , $ this ->conditionProduct ->getMappedSqlField ());
55
53
}
56
54
57
55
public function testAddNonGlobalAttributeToCollectionNoProducts ()
58
56
{
59
57
$ collection = $ this ->objectManager ->create ('Magento\Catalog\Model\Resource\Product\Collection ' );
60
- $ this ->object ->setAttribute ('visibility ' );
61
- $ this ->object ->setOperator ('() ' );
62
- $ this ->object ->setValue ('4 ' );
63
- $ this ->object ->addToCollection ($ collection );
64
- $ collectedAttributes = $ this ->object ->getRule ()->getCollectedAttributes ();
58
+ $ this ->conditionProduct ->setAttribute ('visibility ' );
59
+ $ this ->conditionProduct ->setOperator ('() ' );
60
+ $ this ->conditionProduct ->setValue ('4 ' );
61
+ $ this ->conditionProduct ->addToCollection ($ collection );
62
+ $ collectedAttributes = $ this ->conditionProduct ->getRule ()->getCollectedAttributes ();
65
63
$ this ->assertArrayHasKey ('visibility ' , $ collectedAttributes );
66
64
$ query = (string )$ collection ->getSelect ();
67
65
$ this ->assertNotContains ('visibility ' , $ query );
68
- $ this ->assertEquals ('' , $ this ->object ->getMappedSqlField ());
69
- $ this ->assertFalse ($ this ->object ->hasValueParsed ());
70
- $ this ->assertFalse ($ this ->object ->hasValue ());
66
+ $ this ->assertEquals ('' , $ this ->conditionProduct ->getMappedSqlField ());
67
+ $ this ->assertFalse ($ this ->conditionProduct ->hasValueParsed ());
68
+ $ this ->assertFalse ($ this ->conditionProduct ->hasValue ());
71
69
}
72
70
73
71
/**
@@ -76,14 +74,23 @@ public function testAddNonGlobalAttributeToCollectionNoProducts()
76
74
public function testAddNonGlobalAttributeToCollection ()
77
75
{
78
76
$ collection = $ this ->objectManager ->create ('Magento\Catalog\Model\Resource\Product\Collection ' );
79
- $ this ->object ->setAttribute ('visibility ' );
80
- $ this ->object ->setOperator ('() ' );
81
- $ this ->object ->setValue ('4 ' );
82
- $ this ->object ->addToCollection ($ collection );
83
- $ collectedAttributes = $ this ->object ->getRule ()->getCollectedAttributes ();
77
+ $ this ->conditionProduct ->setAttribute ('visibility ' );
78
+ $ this ->conditionProduct ->setOperator ('() ' );
79
+ $ this ->conditionProduct ->setValue ('4 ' );
80
+ $ this ->conditionProduct ->addToCollection ($ collection );
81
+ $ collectedAttributes = $ this ->conditionProduct ->getRule ()->getCollectedAttributes ();
84
82
$ this ->assertArrayHasKey ('visibility ' , $ collectedAttributes );
85
83
$ query = (string )$ collection ->getSelect ();
86
84
$ this ->assertNotContains ('visibility ' , $ query );
87
- $ this ->assertEquals ('e.entity_id ' , $ this ->object ->getMappedSqlField ());
85
+ $ this ->assertEquals ('e.entity_id ' , $ this ->conditionProduct ->getMappedSqlField ());
86
+ }
87
+
88
+ /**
89
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
90
+ */
91
+ public function testGetMappedSqlFieldCategoryIdsAttribute ()
92
+ {
93
+ $ this ->conditionProduct ->setAttribute ('category_ids ' );
94
+ $ this ->assertEquals ('e.entity_id ' , $ this ->conditionProduct ->getMappedSqlField ());
88
95
}
89
96
}
0 commit comments