_configMock = $this->createPartialMock(\Magento\PageCache\Model\Config::class, ['getType', 'isEnabled']); $this->_typeListMock = $this->createMock(\Magento\Framework\App\Cache\TypeList::class); $this->observerMock = $this->createMock(\Magento\Framework\Event\Observer::class); $this->_model = new \Magento\PageCache\Observer\InvalidateCache( $this->_configMock, $this->_typeListMock ); } /** * @dataProvider invalidateCacheDataProvider * @param bool $cacheState */ public function testExecute($cacheState) { $this->_configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState)); if ($cacheState) { $this->_typeListMock->expects($this->once())->method('invalidate')->with($this->equalTo('full_page')); } $this->_model->execute($this->observerMock); } /** * @return array */ public function invalidateCacheDataProvider() { return [[true], [false]]; } }