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); } }