Skip to content

Commit ef3263c

Browse files
committed
ACP2E-155: [CLOUD] Site Down - php processes are getting OOMKilled cannot upsize largest Starter size
1 parent 147a9a1 commit ef3263c

File tree

1 file changed

+88
-2
lines changed
  • app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition

1 file changed

+88
-2
lines changed

app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\CatalogWidget\Model\Rule\Condition\Product as ProductWidget;
1616
use Magento\Eav\Model\Config;
1717
use Magento\Eav\Model\Entity\AbstractEntity;
18-
use Magento\Framework\DB\Adapter\AdapterInterface;
18+
use Magento\Framework\DB\Adapter\Pdo\Mysql;
1919
use Magento\Framework\DB\Select;
2020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2121
use Magento\SalesRule\Model\Rule;
@@ -63,7 +63,10 @@ protected function setUp(): void
6363
$this->productResource = $this->createMock(Product::class);
6464
$this->productResource->expects($this->once())->method('loadAllAttributes')->willReturnSelf();
6565
$this->productResource->expects($this->once())->method('getAttributesByCode')->willReturn([]);
66-
$connection = $this->getMockForAbstractClass(AdapterInterface::class);
66+
$connection = $this->getMockBuilder(Mysql::class)
67+
->onlyMethods(['_connect'])
68+
->disableOriginalConstructor()
69+
->getMockForAbstractClass();
6770
$this->productResource->method('getConnection')->willReturn($connection);
6871
$productCategoryList = $this->getMockBuilder(ProductCategoryList::class)
6972
->disableOriginalConstructor()
@@ -191,6 +194,89 @@ public function getMappedSqlFieldPriceDataProvider(): array
191194
];
192195
}
193196

197+
/**
198+
* @param array $conditionArray
199+
* @param array $attributeConfig
200+
* @param array $attributeValues
201+
* @param mixed $expected
202+
* @dataProvider getBindArgumentValueDataProvider
203+
*/
204+
public function testGetBindArgumentValue(
205+
array $conditionArray,
206+
array $attributeConfig,
207+
array $attributeValues,
208+
$expected
209+
): void {
210+
$conditionArray['type'] = ProductWidget::class;
211+
$attributeConfig['getAttributeCode'] = $conditionArray['attribute'];
212+
$collectionMock = $this->mockCollection(
213+
[
214+
'getAllAttributeValues' => $attributeValues,
215+
]
216+
);
217+
$this->mockAttribute($attributeConfig);
218+
$this->model->loadArray($conditionArray);
219+
$this->model->collectValidatedAttributes($collectionMock);
220+
$this->assertEquals($expected, $this->model->getBindArgumentValue());
221+
}
222+
223+
/**
224+
* @return array
225+
*/
226+
public function getBindArgumentValueDataProvider(): array
227+
{
228+
return [
229+
[
230+
[
231+
'attribute' => 'attr_1',
232+
'value' => '2',
233+
'operator' => '==',
234+
],
235+
[
236+
'isScopeGlobal' => false,
237+
'getBackendType' => 'int'
238+
],
239+
[
240+
1 => [
241+
0 => 1,
242+
1 => 2
243+
],
244+
2 => [
245+
0 => 1
246+
],
247+
3 => [
248+
1 => 2
249+
]
250+
],
251+
new \Zend_Db_Expr('1, 3')
252+
],
253+
[
254+
[
255+
'attribute' => 'attr_1',
256+
'value' => '2',
257+
'operator' => '==',
258+
],
259+
[
260+
'isScopeGlobal' => true,
261+
'getBackendType' => 'int'
262+
],
263+
[
264+
1 => [
265+
0 => 1,
266+
1 => 2
267+
],
268+
2 => [
269+
0 => 1
270+
],
271+
3 => [
272+
1 => 2
273+
]
274+
],
275+
'2'
276+
],
277+
];
278+
}
279+
194280
/**
195281
* @param array $configuration
196282
*/

0 commit comments

Comments
 (0)