storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->urlBuilderMock = $this->createMock(UrlInterface::class); $this->taxConfigMock = $this->createMock(TaxConfig::class); $this->notificationMock = $this->createMock(NotificationInterface::class); $this->notifications = (new ObjectManager($this))->getObject( Notifications::class, [ 'storeManager' => $this->storeManagerMock, 'urlBuilder' => $this->urlBuilderMock, 'taxConfig' => $this->taxConfigMock, 'notifications' => [$this->notificationMock] ] ); } /** * @dataProvider dataProviderIsDisplayed */ public function testIsDisplayed( $isNotificationDisplayed, $expectedResult ) { $this->notificationMock->expects($this->once())->method('isDisplayed')->willReturn($isNotificationDisplayed); $this->assertEquals($expectedResult, $this->notifications->isDisplayed()); } /** * @return array */ public function dataProviderIsDisplayed() { return [ [true, true], [false, false] ]; } public function testGetText() { $this->notificationMock->expects($this->once())->method('getText')->willReturn('Notification Text.'); $this->taxConfigMock->expects($this->once())->method('getInfoUrl')->willReturn('http://info-url'); $this->urlBuilderMock->expects($this->once())->method('getUrl') ->with('adminhtml/system_config/edit/section/tax')->willReturn('http://tax-config-url'); $this->assertEquals( 'Notification Text.
Please see documentation for more details. ' . 'Click here to go to Tax Configuration and change your settings.
', $this->notifications->getText() ); } }