19 private $canViewNotification;
22 private $viewerLoggerMock;
25 private $productMetadataMock;
34 private $cacheStorageMock;
38 $this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class)
39 ->getMockForAbstractClass();
40 $this->logMock = $this->getMockBuilder(Log::class)
42 $this->sessionMock = $this->getMockBuilder(Session::class)
43 ->disableOriginalConstructor()
44 ->setMethods([
'getUser',
'getId'])
46 $this->viewerLoggerMock = $this->getMockBuilder(Logger::class)
47 ->disableOriginalConstructor()
49 $this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class)
50 ->disableOriginalConstructor()
54 CanViewNotification::class,
56 'viewerLogger' => $this->viewerLoggerMock,
57 'session' => $this->sessionMock,
58 'productMetadata' => $this->productMetadataMock,
59 'cacheStorage' => $this->cacheStorageMock,
66 $this->sessionMock->expects($this->once())
68 ->willReturn($this->sessionMock);
69 $this->sessionMock->expects($this->once())
72 $this->cacheStorageMock->expects($this->once())
74 ->with(
'release-notification-popup-1')
76 $this->assertEquals(
false, $this->canViewNotification->isVisible([]));
87 $this->cacheStorageMock->expects($this->once())
89 ->with(
'release-notification-popup-1')
91 $this->sessionMock->expects($this->once())
93 ->willReturn($this->sessionMock);
94 $this->sessionMock->expects($this->once())
97 $this->productMetadataMock->expects($this->once())
98 ->method(
'getVersion')
100 $this->logMock->expects($this->once())
101 ->method(
'getLastViewVersion')
102 ->willReturn($lastViewVersion);
103 $this->viewerLoggerMock->expects($this->once())
106 ->willReturn($this->logMock);
107 $this->cacheStorageMock->expects($this->once())
109 ->with(
false,
'release-notification-popup-1');
110 $this->assertEquals($expected, $this->canViewNotification->isVisible([]));
119 [
false,
'2.2.1-dev',
'999.999.999-alpha'],
120 [
true,
'2.2.1-dev',
'2.0.0'],
121 [
true,
'2.2.1-dev',
null],
122 [
false,
'2.2.1-dev',
'2.2.1'],
123 [
true,
'2.2.1-dev',
'2.2.0'],
124 [
true,
'2.3.0',
'2.2.0'],
125 [
false,
'2.2.2',
'2.2.2'],
testIsVisible($expected, $version, $lastViewVersion)
testIsVisibleLoadDataFromCache()