@@ -36,7 +36,8 @@ protected function setUp()
36
36
*/
37
37
public function testProductTotals ($ condition , $ expectedTotal , $ expectedDisabled )
38
38
{
39
- $ this ->getRequest ()->setPostValue (['conditionValue ' => $ condition ]);
39
+ $ this ->getRequest ()->setMethod (\Magento \Framework \App \Request \Http::METHOD_POST );
40
+ $ this ->getRequest ()->setPostValue (['conditionValue ' => json_encode ($ condition )]);
40
41
41
42
$ this ->dispatch ('backend/pagebuilder/form/element_producttotals ' );
42
43
$ decoded = $ this ->serializer ->unserialize ($ this ->getResponse ()->getBody ());
@@ -51,60 +52,120 @@ public function testProductTotals($condition, $expectedTotal, $expectedDisabled)
51
52
public function productDataProvider ()
52
53
{
53
54
return [
55
+ // category with no products
54
56
[
55
- // category with no products
56
- '"{"1":{"aggregator":"all","new_child":"", ' .
57
- '"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","value":"1"}, ' .
58
- '"1--1":{"operator":"==","type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product", ' .
59
- '"attribute":"category_ids","value":"4"}}" ' ,
57
+ [
58
+ '1 ' => [
59
+ 'aggregator ' => 'all ' ,
60
+ 'new_child ' => '' ,
61
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
62
+ 'value ' => '1 ' ,
63
+ ],
64
+ '1--1 ' => [
65
+ 'operator ' => '== ' ,
66
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
67
+ 'attribute ' => 'category_ids ' ,
68
+ 'value ' => '2 '
69
+ ],
70
+ ],
60
71
0 ,
61
72
0
62
73
],
74
+ // category with 4 products, 1 disabled
63
75
[
64
- // category with 4 products
65
- '"{"1":{"aggregator":"all","new_child":"", ' .
66
- '"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","value":"1"}, ' .
67
- '"1--1":{"operator":"==","type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product", ' .
68
- '"attribute":"category_ids","value":"3"}}" ' ,
76
+ [
77
+ '1 ' => [
78
+ 'aggregator ' => 'all ' ,
79
+ 'new_child ' => '' ,
80
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
81
+ 'value ' => '1 ' ,
82
+ ],
83
+ '1--1 ' => [
84
+ 'operator ' => '== ' ,
85
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
86
+ 'attribute ' => 'category_ids ' ,
87
+ 'value ' => '3 '
88
+ ],
89
+ ],
69
90
4 ,
70
91
1
71
92
],
93
+ // sku with no matches
72
94
[
73
- // sku with no match
74
- '"{"1":{"aggregator":"all","new_child":"", ' .
75
- '"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","value":"1"}, ' .
76
- '"1--1":{"operator":"()","type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product", ' .
77
- '"attribute":"sku","value":"shoes"}}" ' ,
95
+ [
96
+ '1 ' => [
97
+ 'aggregator ' => 'all ' ,
98
+ 'new_child ' => '' ,
99
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
100
+ 'value ' => '1 ' ,
101
+ ],
102
+ '1--1 ' => [
103
+ 'operator ' => '() ' ,
104
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
105
+ 'attribute ' => 'sku ' ,
106
+ 'value ' => 'shoes '
107
+ ],
108
+ ],
78
109
0 ,
79
110
0
80
111
],
112
+ // sku with 2 matches, 1 disabled
81
113
[
82
- // skus with 2 matches
83
- '"{"1":{"aggregator":"all","new_child":"", ' .
84
- '"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","value":"1"}, ' .
85
- '"1--1":{"operator":"()","type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product", ' .
86
- '"attribute":"sku","value":"simple-3, simple-4"}}" ' ,
114
+ [
115
+ '1 ' => [
116
+ 'aggregator ' => 'all ' ,
117
+ 'new_child ' => '' ,
118
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
119
+ 'value ' => '1 ' ,
120
+ ],
121
+ '1--1 ' => [
122
+ 'operator ' => '() ' ,
123
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
124
+ 'attribute ' => 'sku ' ,
125
+ 'value ' => 'simple-3, simple-4 '
126
+ ],
127
+ ],
87
128
2 ,
88
129
1
89
130
],
131
+ // condition with no matches
90
132
[
91
- // condition with no matches
92
- '"{"1":{"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","aggregator":"all", ' .
93
- '"value":"1","new_child":""}, ' .
94
- '"1--1":{"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product","attribute":"price", ' .
95
- '"operator":">=","value":"10000"}}" ' ,
133
+ [
134
+ '1 ' => [
135
+ 'aggregator ' => 'all ' ,
136
+ 'new_child ' => '' ,
137
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
138
+ 'value ' => '1 ' ,
139
+ ],
140
+ '1--1 ' => [
141
+ 'operator ' => '>= ' ,
142
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
143
+ 'attribute ' => 'price ' ,
144
+ 'value ' => '10000 '
145
+ ],
146
+ ],
96
147
0 ,
97
148
0
98
149
],
150
+ // condition with 3 matches, 1 disabled
99
151
[
100
- // condition with 3 matches
101
- '"{"1":{"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Combine","aggregator":"all", ' .
102
- '"value":"1","new_child":""}, ' .
103
- '"1--1":{"type":"Magento \\CatalogWidget \\Model \\Rule \\Condition \\Product","attribute":"price", ' .
104
- '"operator":"<","value":"20"}}" ' ,
152
+ [
153
+ '1 ' => [
154
+ 'aggregator ' => 'all ' ,
155
+ 'new_child ' => '' ,
156
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Combine::class,
157
+ 'value ' => '1 ' ,
158
+ ],
159
+ '1--1 ' => [
160
+ 'operator ' => '< ' ,
161
+ 'type ' => \Magento \CatalogWidget \Model \Rule \Condition \Product::class,
162
+ 'attribute ' => 'price ' ,
163
+ 'value ' => '20 '
164
+ ],
165
+ ],
105
166
3 ,
106
167
1
107
- ]
168
+ ],
108
169
];
109
170
}
110
171
}
0 commit comments