/** * @magentoAppIsolation enabled */ public function testAddMessages() { $customGroup = 'custom-group'; $messages = array($this->objectManager->create('Magento\\Framework\\Message\\Error', array('text' => 'some text 1')), $this->objectManager->create('Magento\\Framework\\Message\\Error', array('text' => 'some text 2')), $this->objectManager->create('Magento\\Framework\\Message\\Error', array('text' => 'some text 3')), $this->objectManager->create('Magento\\Framework\\Message\\Error', array('text' => 'some text 4'))); $this->model->addMessages($messages); array_shift($messages); $this->model->addMessages($messages, $customGroup); $this->assertEquals(4, $this->model->getMessages()->getCount()); $this->assertEquals(3, $this->model->getMessages(false, $customGroup)->getCount()); }
public function testAddMessages() { $messageCollection = $this->getMock('Magento\\Framework\\Message\\Collection', ['getItems', 'addMessage'], [], '', false); $this->session->expects($this->any())->method('getData')->will($this->returnValue($messageCollection)); $this->eventManager->expects($this->once())->method('dispatch')->with('session_abstract_add_message'); $messageCollection->expects($this->once())->method('addMessage')->with($this->messageMock); $this->model->addMessages([$this->messageMock]); }