1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Backend\Controller\Adminhtml;
- /**
- * @magentoAppArea adminhtml
- */
- class CacheTest extends \Magento\TestFramework\TestCase\AbstractBackendController
- {
- /**
- * @magentoDataFixture Magento/Backend/controllers/_files/cache/application_cache.php
- * @magentoDataFixture Magento/Backend/controllers/_files/cache/non_application_cache.php
- */
- public function testFlushAllAction()
- {
- /** @var $cache \Magento\Framework\App\Cache */
- $cache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Framework\App\Cache::class
- );
- $this->assertNotEmpty($cache->load('APPLICATION_FIXTURE'));
- $this->dispatch('backend/admin/cache/flushAll');
- /** @var $cachePool \Magento\Framework\App\Cache\Frontend\Pool */
- $this->assertFalse($cache->load('APPLICATION_FIXTURE'));
- $cachePool = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Framework\App\Cache\Frontend\Pool::class
- );
- /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
- foreach ($cachePool as $cacheFrontend) {
- $this->assertFalse($cacheFrontend->getBackend()->load('NON_APPLICATION_FIXTURE'));
- }
- }
- /**
- * @magentoDataFixture Magento/Backend/controllers/_files/cache/application_cache.php
- * @magentoDataFixture Magento/Backend/controllers/_files/cache/non_application_cache.php
- */
- public function testFlushSystemAction()
- {
- $this->dispatch('backend/admin/cache/flushSystem');
- /** @var $cache \Magento\Framework\App\Cache */
- $cache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Framework\App\Cache::class
- );
- /** @var $cachePool \Magento\Framework\App\Cache\Frontend\Pool */
- $this->assertFalse($cache->load('APPLICATION_FIXTURE'));
- $cachePool = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Framework\App\Cache\Frontend\Pool::class
- );
- /** @var $cacheFrontend \Magento\Framework\Cache\FrontendInterface */
- foreach ($cachePool as $cacheFrontend) {
- $this->assertSame(
- 'non-application cache data',
- $cacheFrontend->getBackend()->load('NON_APPLICATION_FIXTURE')
- );
- }
- }
- /**
- * @dataProvider massActionsInvalidTypesDataProvider
- * @param $action
- */
- public function testMassActionsInvalidTypes($action)
- {
- $this->getRequest()->setParams(['types' => ['invalid_type_1', 'invalid_type_2', 'config']]);
- $this->dispatch('backend/admin/cache/' . $action);
- $this->assertSessionMessages(
- $this->contains("These cache type(s) don't exist: invalid_type_1, invalid_type_2"),
- \Magento\Framework\Message\MessageInterface::TYPE_ERROR
- );
- }
- /**
- * @return array
- */
- public function massActionsInvalidTypesDataProvider()
- {
- return [
- 'enable' => ['massEnable'],
- 'disable' => ['massDisable'],
- 'refresh' => ['massRefresh']
- ];
- }
- }
|