Skip to content

Commit 57bed0c

Browse files
committed
MAGETWO-39708: Catalog Price Rule has to be applied even if description only was changed
1 parent d6a7f26 commit 57bed0c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,51 @@ public function testAfterUpdate()
226226
$this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer));
227227
$this->rule->afterSave();
228228
}
229+
230+
/**
231+
* Test IsRuleBehaviorChanged action
232+
*
233+
* @dataProvider ruleData
234+
* @param array $dataArray
235+
* @param array $originDataArray
236+
* @param bool $isObjectNew
237+
* @param bool $result
238+
*
239+
* @return void
240+
*/
241+
public function testIsRuleBehaviorChanged($dataArray, $originDataArray, $isObjectNew, $result)
242+
{
243+
$this->rule->setData('website_ids', []);
244+
$this->rule->isObjectNew($isObjectNew);
245+
$indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface');
246+
$indexer->expects($this->any())->method('invalidate');
247+
$this->_ruleProductProcessor->expects($this->any())->method('getIndexer')->will($this->returnValue($indexer));
248+
249+
foreach ($dataArray as $data) {
250+
$this->rule->setData($data);
251+
}
252+
$this->rule->afterSave();
253+
254+
foreach ($originDataArray as $data) {
255+
$this->rule->setOrigData($data);
256+
}
257+
$this->assertEquals($result, $this->rule->isRuleBehaviorChanged());
258+
}
259+
260+
/**
261+
* Data provider for isRuleBehaviorChanged test
262+
*
263+
* @return array
264+
*/
265+
public function ruleData()
266+
{
267+
return [
268+
[['new name', 'new description'], ['name', 'description'], false, false],
269+
[['name', 'description'], ['name', 'description'], false, false],
270+
[['name', 'important_data'], ['name', 'important_data'], false, false],
271+
[['name', 'new important_data'], ['name', 'important_data'], false, true],
272+
[['name', 'description'], ['name', 'description'], true, true],
273+
[['name', 'description'], ['name', 'important_data'], true, true],
274+
];
275+
}
229276
}

0 commit comments

Comments
 (0)