/** * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testAddException() { $exceptionMessage = 'exception message'; $alternativeText = 'alternative text'; $logText = "Exception message: {$exceptionMessage}\nTrace:"; $messageError = $this->getMockBuilder('Magento\\Framework\\Message\\Error')->setConstructorArgs(['text' => $alternativeText])->getMock(); $this->messageFactory->expects($this->atLeastOnce())->method('create')->with(MessageInterface::TYPE_ERROR, $alternativeText)->will($this->returnValue($messageError)); $messageCollection = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods(['addMessage'])->getMock(); $messageCollection->expects($this->atLeastOnce())->method('addMessage')->with($messageError); $this->session->expects($this->atLeastOnce())->method('getData')->with(Manager::DEFAULT_GROUP)->will($this->returnValue($messageCollection)); $exception = new \Exception($exceptionMessage); $this->assertEquals($this->model, $this->model->addException($exception, $alternativeText)); }