|
31 | 31 | class BuilderTest extends TestCase
|
32 | 32 | {
|
33 | 33 | /**
|
34 |
| - * @var Builder |
| 34 | + * @var Builder|null |
35 | 35 | */
|
36 |
| - private Builder $model; |
| 36 | + private ?Builder $model; |
37 | 37 |
|
38 | 38 | /**
|
39 |
| - * @var DataFixtureStorage |
| 39 | + * @var DataFixtureStorage|null |
40 | 40 | */
|
41 |
| - private DataFixtureStorage $fixtures; |
| 41 | + private ?DataFixtureStorage $fixtures; |
42 | 42 |
|
43 | 43 | /**
|
44 | 44 | * @inheritDoc
|
@@ -104,18 +104,10 @@ public function testAttachConditionToCollection(
|
104 | 104 |
|
105 | 105 | $rule->loadPost($ruleConditionArray);
|
106 | 106 | foreach ($rule->getConditions()->getConditions() as $condition) {
|
| 107 | + $condition->addToCollection($collection); |
107 | 108 | if ($condition->getAttribute() === 'multi_select_attr') {
|
108 |
| - $productCollection = $this->createMock(Collection::class); |
109 |
| - $limitationFilters = $this->createMock(ProductLimitation::class); |
110 |
| - $limitationFilters->expects($this->any())->method('isUsingPriceIndex')->willReturn(false); |
111 |
| - $productCollection->expects($this->any()) |
112 |
| - ->method('getLimitationFilters') |
113 |
| - ->willReturn($limitationFilters); |
114 |
| - $productCollection->expects($this->any())->method('isEnabledFlat')->willReturn(true); |
115 |
| - $select = $this->createMock(Select::class); |
116 |
| - $select->expects($this->any())->method('getPart')->willReturn([]); |
117 |
| - $productCollection->expects($this->any())->method('getSelect')->willReturn($select); |
118 |
| - $condition->addToCollection($productCollection); |
| 109 | + $from = array_keys($collection->getSelectSql()->getPart('from')); |
| 110 | + $expectedWhere = str_replace('multi_select_attr', end($from), $expectedWhere); |
119 | 111 | }
|
120 | 112 | }
|
121 | 113 | $this->model->attachConditionToCollection($collection, $rule->getConditions());
|
@@ -159,7 +151,8 @@ public static function attachConditionToCollectionDataProvider(): array
|
159 | 151 | ],
|
160 | 152 | "(((`e`.`entity_id` IN (SELECT `catalog_category_product`.`product_id` FROM " .
|
161 | 153 | "`catalog_category_product` WHERE (category_id IN ('3')))) " .
|
162 |
| - "AND(`e`.`entity_id` = '2017-09-15 00:00:00') " . |
| 154 | + "AND(IF(`at_special_to_date`.`value_id` > 0, `at_special_to_date`.`value`, " . |
| 155 | + "`at_special_to_date_default`.`value`) = '2017-09-15 00:00:00') " . |
163 | 156 | "AND(`e`.`sku` IN ('sku1', 'sku2', 'sku3', 'sku4', 'sku5'))",
|
164 | 157 | "ORDER BY (FIELD(`e`.`sku`, 'sku1', 'sku2', 'sku3', 'sku4', 'sku5'))"
|
165 | 158 | ],
|
@@ -192,10 +185,9 @@ public static function attachConditionToCollectionDataProvider(): array
|
192 | 185 | ],
|
193 | 186 | "(((`e`.`entity_id` IN (SELECT `catalog_category_product`.`product_id` FROM " .
|
194 | 187 | "`catalog_category_product` WHERE (category_id IN ('3')))) " .
|
195 |
| - "AND(`e`.`sku` IN ('sku1', 'sku2', 'sku3')) AND(`at_multi_select_attr`.`value` IN " . |
196 |
| - "('red', 'white') OR " . |
197 |
| - "(FIND_IN_SET ('red', `at_multi_select_attr`.`value`) > 0) OR " . |
198 |
| - "(FIND_IN_SET ('white', `at_multi_select_attr`.`value`) > 0))", |
| 188 | + "AND(`e`.`sku` IN ('sku1', 'sku2', 'sku3')) AND(`multi_select_attr`.`value` IN ('red', 'white') OR " . |
| 189 | + "(FIND_IN_SET ('red', `multi_select_attr`.`value`) > 0) OR " . |
| 190 | + "(FIND_IN_SET ('white', `multi_select_attr`.`value`) > 0))", |
199 | 191 | "ORDER BY (FIELD(`e`.`sku`, 'sku1', 'sku2', 'sku3'))"
|
200 | 192 | ]
|
201 | 193 | ];
|
|
0 commit comments