UpdateTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Widget\Model\ResourceModel\Layout;
  7. class UpdateTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Widget\Model\ResourceModel\Layout\Update
  11. */
  12. protected $_resourceModel;
  13. protected function setUp()
  14. {
  15. $this->_resourceModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  16. \Magento\Widget\Model\ResourceModel\Layout\Update::class
  17. );
  18. }
  19. /**
  20. * @magentoDataFixture Magento/Widget/_files/layout_update.php
  21. */
  22. public function testFetchUpdatesByHandle()
  23. {
  24. /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
  25. $theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  26. \Magento\Framework\View\Design\ThemeInterface::class
  27. );
  28. $theme->load('Test Theme', 'theme_title');
  29. $result = $this->_resourceModel->fetchUpdatesByHandle(
  30. 'test_handle',
  31. $theme,
  32. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  33. \Magento\Store\Model\StoreManagerInterface::class
  34. )->getStore()
  35. );
  36. $this->assertEquals('not_temporary', $result);
  37. }
  38. /**
  39. * @magentoDataFixture Magento/Backend/controllers/_files/cache/application_cache.php
  40. * @magentoDataFixture Magento/Widget/_files/layout_cache.php
  41. */
  42. public function testSaveAfterClearCache()
  43. {
  44. /** @var $appCache \Magento\Framework\App\Cache */
  45. $appCache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  46. \Magento\Framework\App\Cache::class
  47. );
  48. /** @var \Magento\Framework\App\Cache\Type\Layout $layoutCache */
  49. $layoutCache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  50. \Magento\Framework\App\Cache\Type\Layout::class
  51. );
  52. $this->assertNotEmpty($appCache->load('APPLICATION_FIXTURE'));
  53. $this->assertNotEmpty($layoutCache->load('LAYOUT_CACHE_FIXTURE'));
  54. /** @var $layoutUpdate \Magento\Widget\Model\Layout\Update */
  55. $layoutUpdate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  56. \Magento\Widget\Model\Layout\Update::class
  57. );
  58. $layoutUpdate->setHasDataChanges(true);
  59. $this->_resourceModel->save($layoutUpdate);
  60. $this->assertNotEmpty($appCache->load('APPLICATION_FIXTURE'), 'Non-layout cache must be kept');
  61. $this->assertFalse($layoutCache->load('LAYOUT_CACHE_FIXTURE'), 'Layout cache must be erased');
  62. }
  63. }