Files
Matthew O'Loughlin 99b26a4f9c Merge remote-tracking branch 'origin/2.4-develop' into fix/cache_invalidate_incorrect_tag_splitting
Conflicts:
	app/code/Magento/CacheInvalidate/Test/Unit/Model/PurgeCacheTest.php
	app/code/Magento/CacheInvalidate/Test/Unit/Observer/FlushAllCacheObserverTest.php
2020-05-13 08:32:58 +09:30

63 lines
1.7 KiB
PHP

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\CacheInvalidate\Test\Unit\Observer;
use Magento\CacheInvalidate\Model\PurgeCache;
use Magento\CacheInvalidate\Observer\FlushAllCacheObserver;
use Magento\Framework\Event\Observer;
use Magento\PageCache\Model\Config;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class FlushAllCacheObserverTest extends TestCase
{
/** @var MockObject|FlushAllCacheObserver */
protected $model;
/** @var MockObject|Observer */
protected $observerMock;
/** @var MockObject|Config */
protected $configMock;
/** @var MockObject|PurgeCache */
protected $purgeCache;
/**
* Set up all mocks and data for test
*/
protected function setUp(): void
{
$this->configMock = $this->createPartialMock(Config::class, ['getType', 'isEnabled']);
$this->purgeCache = $this->createMock(PurgeCache::class);
$this->model = new FlushAllCacheObserver(
$this->configMock,
$this->purgeCache
);
$this->observerMock = $this->createPartialMock(Observer::class, ['getEvent']);
}
/**
* Test case for flushing all the cache
*/
public function testFlushAllCache()
{
$this->configMock->expects($this->once())->method('isEnabled')->willReturn(true);
$this->configMock->expects(
$this->once()
)->method(
'getType'
)->willReturn(
Config::VARNISH
);
$this->purgeCache->expects($this->once())->method('sendPurgeRequest')->with(['.*']);
$this->model->execute($this->observerMock);
}
}