16 private $notificationStorage;
26 private $serializerMock;
30 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
31 $this->cacheMock = $this->createMock(\
Magento\Framework\
Cache\FrontendInterface::class);
33 NotificationStorage::class,
34 [
'cache' => $this->cacheMock]
36 $this->serializerMock = $this->createMock(\
Magento\Framework\
Serialize\SerializerInterface::class);
37 $objectManager->setBackwardCompatibleProperty($this->notificationStorage,
'serializer', $this->serializerMock);
43 $notificationType =
'some_type';
46 'notification_type' => $notificationType
48 $serializedData =
'serialized data';
49 $this->serializerMock->expects($this->once())
52 ->willReturn($serializedData);
53 $this->cacheMock->expects($this->once())
59 $this->notificationStorage->add($notificationType,
$customerId);
65 $notificationType =
'some_type';
66 $this->cacheMock->expects($this->once())
68 ->with($this->getCacheKey($notificationType,
$customerId))
70 $this->assertTrue($this->notificationStorage->isExists($notificationType,
$customerId));
76 $notificationType =
'some_type';
77 $this->cacheMock->expects($this->once())
79 ->with($this->getCacheKey($notificationType,
$customerId));
80 $this->notificationStorage->remove($notificationType,
$customerId);
90 private function getCacheKey($notificationType,
$customerId)
92 return 'notification_' . $notificationType .
'_' .
$customerId;