public function setUp() { $this->priceCurrency = $this->getMockBuilder('Magento\\Framework\\Pricing\\PriceCurrencyInterface')->getMock(); $this->priceCurrency->expects($this->any())->method('round')->will($this->returnCallback(function ($argument) { return round($argument, 2); })); $this->_model = new \Magento\Framework\Math\Calculator($this->priceCurrency); }
public function setUp() { $this->_scopeMock = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false); $this->_scopeMock->expects($this->any())->method('roundPrice')->will($this->returnCallback(function ($argument) { return round($argument, 2); })); $this->_model = new \Magento\Framework\Math\Calculator($this->_scopeMock); }
protected function setUp() { $this->argumentsReaderMock = $this->getMock('\\Magento\\Framework\\Code\\Reader\\ArgumentsReader', [], [], '', false); $this->argumentsReaderMock->expects($this->any())->method('isCompatibleType')->will($this->returnCallback(function ($arg1, $arg2) { return ltrim($arg1, '\\') == ltrim($arg2, '\\'); })); $this->model = new InterfaceValidator($this->argumentsReaderMock); }
protected function mockComposerObjects($packageExtraValue = null) { $this->composerMock = $this->getMock('Composer\\Composer', array('getPackage')); $this->packageMock = $this->getMockForAbstractClass('Composer\\Package\\PackageInterface'); $this->packageMock->expects($this->any())->method('getExtra')->will($this->returnValue($packageExtraValue)); $this->composerMock->expects($this->any())->method('getPackage')->will($this->returnValue($this->packageMock)); $this->composerEventMock = $this->getMock('Composer\\Script\\Event', array('getComposer'), array('postPackageUpdate', $this->composerMock, $this->getMockForAbstractClass('Composer\\IO\\IOInterface'), true)); $this->composerEventMock->expects($this->any())->method('getComposer')->will($this->returnValue($this->composerMock)); }
public function testGetDefaultResultClassName() { // resultClassName should be stdClass_Interceptor $model = $this->getMock('\\Magento\\Framework\\Interception\\Code\\Generator\\Interceptor', ['_validateData'], ['Exception', null, $this->ioObjectMock, $this->classGeneratorMock]); $this->classGeneratorMock->expects($this->once())->method('setName')->will($this->returnValue($this->classGeneratorMock)); $this->classGeneratorMock->expects($this->once())->method('addProperties')->will($this->returnValue($this->classGeneratorMock)); $this->classGeneratorMock->expects($this->once())->method('addMethods')->will($this->returnValue($this->classGeneratorMock)); $this->classGeneratorMock->expects($this->once())->method('setClassDocBlock')->will($this->returnValue($this->classGeneratorMock)); $this->classGeneratorMock->expects($this->once())->method('generate')->will($this->returnValue('source code example')); $model->expects($this->once())->method('_validateData')->will($this->returnValue(true)); $this->ioObjectMock->expects($this->any())->method('getResultFileName')->with('Exception_Interceptor'); $this->assertEquals('', $model->generate()); }
/** * @param string $messageType * @param string $method * * @covers \Magento\Framework\Mail\Message::getBody * @covers \Magento\Framework\Mail\Message::setMessageType * @dataProvider getBodyDataProvider */ public function testGetBody($messageType, $method) { $this->_messageMock->setMessageType($messageType); $this->_messageMock->expects($this->once())->method($method); $this->_messageMock->getBody('body'); }
/** * @covers \Magento\Framework\Mail\Transport::sendMessage * @expectedException \Magento\Framework\Exception\MailException * @expectedExceptionMessage No body specified */ public function testSendMessageBrokenMessage() { $this->_messageMock->expects($this->any())->method('getParts')->will($this->returnValue(['a', 'b'])); $this->_transport->sendMessage(); }
/** * @covers \Magento\Framework\Mail\Template\Factory::get * @covers \Magento\Framework\Mail\Template\Factory::__construct */ public function testGet() { $model = new \Magento\Framework\Mail\Template\Factory($this->_objectManagerMock); $this->_objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Mail\\TemplateInterface', array('data' => array('template_id' => 'identifier')))->will($this->returnValue($this->_templateMock)); $this->assertInstanceOf('\\Magento\\Framework\\Mail\\TemplateInterface', $model->get('identifier')); }