示例#1
0
 public function testAddSuccess()
 {
     $messageText = 'Some message success text';
     $message = $this->getMock('Magento\\Framework\\Message\\MessageInterface');
     $this->messageFactory->expects($this->once())->method('create')->with(MessageInterface::TYPE_SUCCESS, $messageText)->will($this->returnValue($message));
     $collection = $this->initMessageCollection();
     $collection->expects($this->once())->method('addMessage')->with($message);
     $this->assertSame($this->messages, $this->messages->addSuccess($messageText));
 }
示例#2
0
 /**
  * @param string $type
  * @param string $methodName
  * @dataProvider addMessageDataProvider
  */
 public function testAddMessage($type, $methodName)
 {
     $this->assertFalse($this->model->hasMessages());
     $message = 'Message';
     $messageCollection = $this->getMock('Magento\\Framework\\Message\\Collection', ['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');
     $this->messageFactory->expects($this->once())->method('create')->with($type, $message)->will($this->returnValue($this->messageMock));
     $this->model->{$methodName}($message, 'group');
     $this->assertTrue($this->model->hasMessages());
 }