Beispiel #1
0
 /**
  * Set up before test
  *
  * @throws Exception
  */
 public function setUp()
 {
     $this->appMock = $this->getMock(\Magelight\App::class, [], [], '', false);
     \Magelight\App::forgeMock($this->appMock);
     $this->configLoaderMock = $this->getMock(\Magelight\Components\Loaders\Config::class, ['getConfig', 'loadConfig', 'getModulesConfigFilePath'], [], '', false);
     \Magelight\Components\Loaders\Config::forgeMock($this->configLoaderMock);
     $this->modulesMock = $this->getMock(\Magelight\Components\Modules::class, [], [], '', false);
     \Magelight\Components\Modules::forgeMock($this->modulesMock);
     $this->cacheAdapterPoolMock = $this->getMock(\Magelight\Cache\AdapterPool::class, [], [], '', false);
     \Magelight\Cache\AdapterPool::forgeMock($this->cacheAdapterPoolMock);
     $this->cacheAdapterMock = $this->getMockForAbstractClass(\Magelight\Cache\AdapterAbstract::class, [], '', false, false, true, []);
     $this->cacheAdapterPoolMock->expects($this->any())->method('getAdapter')->will($this->returnValue($this->cacheAdapterMock));
     $this->config = \Magelight\Config::forge();
 }
Beispiel #2
0
 public function testToHtmlCacheMiss()
 {
     $cacheAdapterPoolMock = $this->getMock(\Magelight\Cache\AdapterPool::class, [], [], '', false);
     \Magelight\Cache\AdapterPool::forgeMock($cacheAdapterPoolMock);
     $cacheAdapterMock = $this->getMockForAbstractClass(\Magelight\Cache\AdapterAbstract::class, [], '', false, false, true, []);
     $cacheAdapterPoolMock->expects($this->any())->method('getAdapter')->will($this->returnValue($cacheAdapterMock));
     $block = \Magelight\Block::forge();
     $block->useCache('cache_key');
     $block->setTemplate(__DIR__ . DS . '_fixtures' . DS . 'test_block_template.phtml');
     $cacheAdapterMock->expects($this->once())->method('set')->with('e4453472c2481215f49f028d80db65d7', '<div>7</div>', 3600);
     $this->assertEquals('<div>7</div>', $block->toHtml());
 }
Beispiel #3
0
 /**
  * @param $cacheReturnValue
  * @param $expectedResult
  *
  * @dataProvider testUnlockActionDataProvider
  */
 public function testUnlockAction($cacheReturnValue, $expectedResult)
 {
     $cacheMock = $this->getMockForAbstractClass(\Magelight\Cache\AdapterAbstract::class, [], '', false, false, true, ['del']);
     $adapterPoolMock = $this->getMock(\Magelight\Cache\AdapterPool::class, [], [], '', false);
     \Magelight\Cache\AdapterPool::forgeMock($adapterPoolMock);
     $adapterPoolMock->expects($this->any())->method('getAdapter')->will($this->returnValue($cacheMock));
     $cacheMock->expects($this->any())->method('del')->with(md5(serialize([]) . '_lock'))->will($this->returnValue($cacheReturnValue));
     $this->controller->init();
     $this->assertEquals($expectedResult, $this->controller->unlockCurrentAction());
 }
Beispiel #4
0
 public function testFlushAllCache()
 {
     $cacheConfig = new \SimpleXMLElement('<cache>
         <default>
             <type>file</type>
             <config>
                 <path>var/cache</path>
             </config>
         </default>
         <other>
             <memcache>
                 <server>
                     <host>127.0.0.1</host>
                     <port>11211</port>
                 </server>
             </memcache>
         </other>
     </cache>');
     $this->configMock->expects($this->once())->method('getConfig')->with('global/cache')->will($this->returnValue($cacheConfig));
     $adapterPoolMock = $this->getMock(\Magelight\Cache\AdapterPool::class, [], [], '', false);
     \Magelight\Cache\AdapterPool::forgeMock($adapterPoolMock);
     $adapterMock = $this->getMockForAbstractClass(\Magelight\Cache\AdapterAbstract::class, [], '', false, false, true, ['clear']);
     $adapterMock->expects($this->exactly(2))->method('clear');
     $adapterPoolMock->expects($this->at(0))->method('getAdapter')->with('default')->will($this->returnValue($adapterMock));
     $adapterPoolMock->expects($this->at(1))->method('getAdapter')->with('other')->will($this->returnValue($adapterMock));
     $this->app->flushAllCache();
 }