Skip to content

Commit 898eacc

Browse files
committed
PB-107: Display total number of products matched into ProductsList
- populate total number of products
1 parent 18b7b33 commit 898eacc

File tree

1 file changed

+93
-32
lines changed
  • dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Form/Element

1 file changed

+93
-32
lines changed

dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductTotalsTest.php

Lines changed: 93 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ protected function setUp()
3636
*/
3737
public function testProductTotals($condition, $expectedTotal, $expectedDisabled)
3838
{
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)]);
4041

4142
$this->dispatch('backend/pagebuilder/form/element_producttotals');
4243
$decoded = $this->serializer->unserialize($this->getResponse()->getBody());
@@ -51,60 +52,120 @@ public function testProductTotals($condition, $expectedTotal, $expectedDisabled)
5152
public function productDataProvider()
5253
{
5354
return [
55+
// category with no products
5456
[
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+
],
6071
0,
6172
0
6273
],
74+
// category with 4 products, 1 disabled
6375
[
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+
],
6990
4,
7091
1
7192
],
93+
// sku with no matches
7294
[
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+
],
78109
0,
79110
0
80111
],
112+
// sku with 2 matches, 1 disabled
81113
[
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+
],
87128
2,
88129
1
89130
],
131+
// condition with no matches
90132
[
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+
],
96147
0,
97148
0
98149
],
150+
// condition with 3 matches, 1 disabled
99151
[
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+
],
105166
3,
106167
1
107-
]
168+
],
108169
];
109170
}
110171
}

0 commit comments

Comments
 (0)