-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from magento-mpi/develop
[MPI] Optimization and bug fixes
- Loading branch information
Showing
32 changed files
with
1,085 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/code/Magento/OfflinePayments/Block/Form/AbstractInstruction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\OfflinePayments\Block\Form; | ||
|
||
/** | ||
* Abstract class for Cash On Delivery and Bank Transfer payment method form | ||
*/ | ||
abstract class AbstractInstruction extends \Magento\Payment\Block\Form | ||
{ | ||
/** | ||
* Instructions text | ||
* | ||
* @var string | ||
*/ | ||
protected $_instructions; | ||
|
||
/** | ||
* Get instructions text from config | ||
* | ||
* @return string | ||
*/ | ||
public function getInstructions() | ||
{ | ||
if (is_null($this->_instructions)) { | ||
$this->_instructions = $this->getMethod()->getInstructions(); | ||
} | ||
return $this->_instructions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
dev/tests/unit/testsuite/Magento/OfflinePayments/Block/Form/AbstractInstructionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\OfflinePayments\Block\Form; | ||
|
||
class AbstractInstructionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\OfflinePayments\Block\Form\AbstractInstruction | ||
*/ | ||
protected $_model; | ||
|
||
protected function setUp() | ||
{ | ||
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); | ||
$this->_model = $this->getMockForAbstractClass( | ||
'Magento\OfflinePayments\Block\Form\AbstractInstruction', | ||
['context' => $context] | ||
); | ||
} | ||
|
||
public function testGetInstructions() | ||
{ | ||
$method = $this->getMock( | ||
'Magento\Payment\Model\MethodInterface', | ||
['getInstructions', 'getCode', 'getFormBlockType', 'getTitle'], | ||
[], | ||
'', | ||
false | ||
); | ||
$method->expects($this->once()) | ||
->method('getInstructions') | ||
->willReturn('instructions'); | ||
$this->_model->setData('method', $method); | ||
|
||
$this->assertEquals('instructions', $this->_model->getInstructions()); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
dev/tests/unit/testsuite/Magento/OfflinePayments/Block/Info/CheckmoTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\OfflinePayments\Block\Info; | ||
|
||
class CheckmoTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\OfflinePayments\Block\Info\Checkmo | ||
*/ | ||
protected $_model; | ||
|
||
protected function setUp() | ||
{ | ||
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); | ||
$this->_model = new \Magento\OfflinePayments\Block\Info\Checkmo($context); | ||
} | ||
|
||
/** | ||
* @dataProvider getPayableToDataProvider | ||
*/ | ||
public function testGetPayableTo($details, $expected) | ||
{ | ||
$info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); | ||
$info->expects($this->once()) | ||
->method('getAdditionalData') | ||
->willReturn(serialize($details)); | ||
$this->_model->setData('info', $info); | ||
|
||
$this->assertEquals($expected, $this->_model->getPayableTo()); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getPayableToDataProvider() | ||
{ | ||
return [ | ||
[['payable_to' => 'payable'], 'payable'], | ||
['', ''] | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider getMailingAddressDataProvider | ||
*/ | ||
public function testGetMailingAddress($details, $expected) | ||
{ | ||
$info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); | ||
$info->expects($this->once()) | ||
->method('getAdditionalData') | ||
->willReturn(serialize($details)); | ||
$this->_model->setData('info', $info); | ||
|
||
$this->assertEquals($expected, $this->_model->getMailingAddress()); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getMailingAddressDataProvider() | ||
{ | ||
return [ | ||
[['mailing_address' => 'blah@blah.com'], 'blah@blah.com'], | ||
['', ''] | ||
]; | ||
} | ||
|
||
public function testConvertAdditionalDataIsNeverCalled() | ||
{ | ||
$info = $this->getMock('Magento\Payment\Model\Info', ['getAdditionalData'], [], '', false); | ||
$info->expects($this->once()) | ||
->method('getAdditionalData') | ||
->willReturn(serialize(['mailing_address' => 'blah@blah.com'])); | ||
$this->_model->setData('info', $info); | ||
|
||
// First we set the property $this->_mailingAddress | ||
$this->_model->getMailingAddress(); | ||
|
||
// And now we get already setted property $this->_mailingAddress | ||
$this->assertEquals('blah@blah.com', $this->_model->getMailingAddress()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.