Skip to content

Commit afaefb3

Browse files
author
Hayder Sharhan
committed
MAGETWO-50551: When saving product or category cache cleared by general tag
- Fix unit test.
1 parent 685414a commit afaefb3

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

app/code/Magento/CacheInvalidate/Test/Unit/Observer/InvalidateVarnishObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function setUp()
5555
public function testInvalidateVarnish()
5656
{
5757
$tags = ['cache_1', 'cache_group'];
58-
$pattern = '((^|,)cache(,|$))|((^|,)cache_1(,|$))|((^|,)cache_group(,|$))';
58+
$pattern = '((^|,)cache_1(,|$))|((^|,)cache_group(,|$))';
5959

6060
$this->configMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
6161
$this->configMock->expects(

app/code/Magento/Catalog/Model/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ public function getIdentities()
22682268
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
22692269
}
22702270
}
2271-
if ($this->getAppState()->getAreaCode() === \Magento\Framework\App\Area::AREA_FRONTEND) {
2271+
if ($this->getAppState()->getAreaCode() == \Magento\Framework\App\Area::AREA_FRONTEND) {
22722272
$identities[] = self::CACHE_TAG;
22732273
}
22742274
return array_unique($identities);

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ class ProductTest extends \PHPUnit_Framework_TestCase
166166
/** @var \PHPUnit_Framework_MockObject_MockObject */
167167
protected $mediaConfig;
168168

169+
/**
170+
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
171+
*/
172+
private $appStateMock;
173+
169174
/**
170175
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
171176
*/
@@ -365,6 +370,14 @@ protected function setUp()
365370
]
366371
);
367372

373+
$this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class)
374+
->disableOriginalConstructor()
375+
->setMethods([])
376+
->getMock();
377+
$modelReflection = new \ReflectionClass(get_class($this->model));
378+
$appStateReflection = $modelReflection->getProperty('appState');
379+
$appStateReflection->setAccessible(true);
380+
$appStateReflection->setValue($this->model, $this->appStateMock);
368381
}
369382

370383
public function testGetAttributes()

app/code/Magento/PageCache/Test/Unit/Observer/FlushCacheByTagsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testExecute($cacheState)
6262

6363
if ($cacheState) {
6464
$tags = ['cache_1', 'cache_group'];
65-
$expectedTags = ['cache_1', 'cache_group', 'cache'];
65+
$expectedTags = ['cache_1', 'cache_group'];
6666

6767
$eventMock = $this->getMock('Magento\Framework\Event', ['getObject'], [], '', false);
6868
$eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject));

0 commit comments

Comments
 (0)