本文整理汇总了PHP中Magento\Framework\Message\Manager::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::getMessages方法的具体用法?PHP Manager::getMessages怎么用?PHP Manager::getMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Message\Manager
的用法示例。
在下文中一共展示了Manager::getMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMessagesWithClear
public function testGetMessagesWithClear()
{
$messageCollection = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods(['addMessage', 'clear'])->getMock();
$messageCollection->expects($this->once())->method('clear');
$this->session->expects($this->any())->method('getData')->with(Manager::DEFAULT_GROUP)->will($this->returnValue($messageCollection));
$this->eventManager->expects($this->once())->method('dispatch')->with('session_abstract_clear_messages');
$this->assertEquals($messageCollection, $this->model->getMessages(true));
}
示例2: testAddError
/**
* @magentoAppIsolation enabled
*/
public function testAddError()
{
$customGroup = 'custom-group';
$this->model->addError('some text');
$this->model->addError('some text 2', $customGroup);
$this->assertEquals(1, $this->model->getMessages()->getCount());
$this->assertEquals(1, $this->model->getMessages()->getCountByType(MessageInterface::TYPE_ERROR));
$this->assertEquals(0, $this->model->getMessages()->getCountByType(MessageInterface::TYPE_WARNING));
$this->assertEquals(0, $this->model->getMessages()->getCountByType(MessageInterface::TYPE_NOTICE));
$this->assertEquals(0, $this->model->getMessages()->getCountByType(MessageInterface::TYPE_SUCCESS));
$this->assertEquals('some text', $this->model->getMessages()->getLastAddedMessage()->getText());
$this->assertEquals(1, $this->model->getMessages(false, $customGroup)->getCount());
$this->assertEquals('some text 2', $this->model->getMessages(false, $customGroup)->getLastAddedMessage()->getText());
}