Skip to content

Commit fd21df8

Browse files
committed
MAGETWO-33583: Catalog page is not updated when a product status changes
1 parent 38f13c2 commit fd21df8

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,20 @@ public function testIndexerAfterDeleteCommitProduct()
383383
public function testReindex($productChanged, $isScheduled, $productFlatCount, $categoryIndexerCount)
384384
{
385385
$this->model->setData('entity_id', 1);
386-
$this->_catalogProduct->expects($this->once())->method('isDataForProductCategoryIndexerWasChanged')->willReturn($productChanged);
386+
$this->_catalogProduct->expects($this->once())
387+
->method('isDataForProductCategoryIndexerWasChanged')
388+
->willReturn($productChanged);
389+
if ($productChanged) {
390+
$this->indexerRegistryMock->expects($this->exactly($productFlatCount))
391+
->method('get')
392+
->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
393+
->will($this->returnValue($this->categoryIndexerMock));
394+
$this->categoryIndexerMock->expects($this->any())
395+
->method('isScheduled')
396+
->will($this->returnValue($isScheduled));
397+
$this->categoryIndexerMock->expects($this->exactly($categoryIndexerCount))->method('reindexRow');
398+
}
387399
$this->productFlatProcessor->expects($this->exactly($productFlatCount))->method('reindexRow');
388-
$this->indexerRegistryMock->expects($this->exactly($productFlatCount))
389-
->method('get')
390-
->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
391-
->will($this->returnValue($this->categoryIndexerMock));
392-
$this->categoryIndexerMock->expects($this->any())->method('isScheduled')->will($this->returnValue($isScheduled));
393-
$this->categoryIndexerMock->expects($this->exactly($categoryIndexerCount))->method('reindexRow');
394-
395400
$this->model->reindex();
396401
}
397402

@@ -400,7 +405,7 @@ public function getProductReindexProvider()
400405
return array(
401406
'set 1' => [true, false, 1, 1],
402407
'set 2' => [true, true, 1, 0],
403-
'set 3' => [false, false, 0, 0]
408+
'set 3' => [false, false, 1, 0]
404409
);
405410
}
406411

@@ -465,6 +470,21 @@ public function getIdentitiesProvider()
465470
'affected_category_ids' => [1],
466471
'is_changed_categories' => true
467472
]
473+
],
474+
[
475+
[0 => 'catalog_product_1', 1 => 'catalog_category_product_1'],
476+
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
477+
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
478+
],
479+
[
480+
[0 => 'catalog_product_1'],
481+
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
482+
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
483+
],
484+
[
485+
[0 => 'catalog_product_1'],
486+
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
487+
['id' => 1, 'name' => 'value', 'category_ids' => [], 'status' => 1],
468488
]
469489
];
470490
}

0 commit comments

Comments
 (0)