/** * @expectedException \Magelight\Exception * @expectedExceptionMessage Observer '\Magelight\Observer' method 'unexistentMethod' does not exist or is not callable! */ public function testDispatchEventException() { $eventName = 'test_event'; $observerClass1 = '\\Magelight\\Observer::unexistentMethod'; $observers = [$observerClass1]; $this->configMock->expects($this->once())->method('getConfigSet')->with('global/events/' . $eventName . '/observer')->will($this->returnValue($observers)); $observerMock = $this->getMockForAbstractClass('\\Magelight\\Observer', [], '', false, false, true, ['execute']); \Magelight\Observer::forgeMock($observerMock); $this->eventManager->dispatchEvent('test_event'); }
public function testGetAdapter() { $cacheConfig = new \SimpleXMLElement('<default> <type>file</type> <config> <path>var/cache</path> </config> </default> '); $this->configMock->expects($this->once())->method('getConfig')->with('global/cache/default')->will($this->returnValue($cacheConfig)); $fileAdapterMock = $this->getMock(\Magelight\Cache\Adapter\File::class, [], [], '', false); \Magelight\Cache\Adapter\File::forgeMock($fileAdapterMock); $this->assertEquals($fileAdapterMock, $this->adapterPool->getAdapter()); }
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(); }