createPartialMock(\Magento\Indexer\Model\Indexer\Collection::class, ['getItems']); $this->indexerMock = $this->createPartialMock(\Magento\Indexer\Model\Indexer::class, ['getStatus']); $urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class); $collectionMock->expects($this->any())->method('getItems')->with()->willReturn([$this->indexerMock]); $this->model = new \Magento\Indexer\Model\Message\Invalid( $collectionMock, $urlBuilder ); } public function testDisplayMessage() { $this->indexerMock->expects($this->any())->method('getStatus')->with() ->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->assertTrue($this->model->isDisplayed()); } public function testHideMessage() { $this->indexerMock->expects($this->any())->method('getStatus')->with() ->willReturn('Status other than "invalid"'); $this->assertFalse($this->model->isDisplayed()); } }