cacheStorageMock = $this->getMockBuilder(CacheInterface::class) ->getMockForAbstractClass(); $this->logMock = $this->createMock(Log::class); $this->viewerLoggerMock = $this->createMock(Logger::class); $this->productMetadataMock = $this->getMockForAbstractClass(ProductMetadataInterface::class); $objectManager = new ObjectManager($this); $this->canViewNotification = $objectManager->getObject( CanViewNotification::class, [ 'viewerLogger' => $this->viewerLoggerMock, 'productMetadata' => $this->productMetadataMock, 'cacheStorage' => $this->cacheStorageMock, ] ); } /** * @param $expected * @param $cacheResponse * @param $logExists * @dataProvider isVisibleProvider */ public function testIsVisibleLoadDataFromLog($expected, $cacheResponse, $logExists) { $this->cacheStorageMock->expects($this->once()) ->method('load') ->with('admin-usage-notification-popup') ->willReturn($cacheResponse); $this->viewerLoggerMock ->method('checkLogExists') ->willReturn($logExists); $this->cacheStorageMock ->method('save') ->with('log-exists', 'admin-usage-notification-popup'); $this->assertEquals($expected, $this->canViewNotification->isVisible([])); } /** * @return array */ public function isVisibleProvider() { return [ [true, false, false], [false, 'log-exists', true], [false, false, true], ]; } }