Skip to content

Commit

Permalink
Merge pull request #158 from mollie/5.5.4
Browse files Browse the repository at this point in the history
5.5.4
  • Loading branch information
Marvin-Magmodules authored Dec 3, 2019
2 parents 5a095d8 + d0347fb commit f3e6c8d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app/code/community/Mollie/Mpm/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,11 @@ public function getStatusPending($storeId = null)

/**
* @param Mage_Sales_Model_Order $order
* @param null $status
* @param null $status
*
* @return bool
* @throws Mage_Core_Exception
* @throws Exception
*/
public function registerCancellation(Mage_Sales_Model_Order $order, $status = null)
{
Expand All @@ -642,7 +643,13 @@ public function registerCancellation(Mage_Sales_Model_Order $order, $status = nu
}

$this->addTolog('info', $order->getIncrementId() . ' ' . $comment);
$order->registerCancellation($comment)->save();
$order->cancel();

if ($status !== null) {
$order->addStatusHistoryComment($comment);
}

$order->save();
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function collect(Mage_Sales_Model_Quote_Address $address)
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$amount = $address->getMollieMpmPaymentFee();
if ($amount) {
if (floatval($amount)) {
$address->addTotal(
array(
'code' => $this->getCode(),
Expand Down
30 changes: 30 additions & 0 deletions app/code/community/Mollie/Mpm/Test/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,34 @@ public function testGetInvoiceMomentPaidStatusThrowsAnExceptionWhenAWrongMomentI
$this->assertEquals('Invoice moment not supported: shipment', $exception->getMessage());
}
}

public function testRegisterCancellation()
{
$order = $this->createMock(Mage::getConfig()->getModelClassName('sales/order'));
$order->expects($this->once())->method('cancel');
$order->expects($this->never())->method('addStatusHistoryComment');
$order->method('getId')->willReturn(-999);

/** @var Mollie_Mpm_Helper_data $instance */
$instance = Mage::helper('mpm');

$instance->registerCancellation($order);
}

public function testRegisterCancellationWithStatus()
{
$order = $this->createMock(Mage::getConfig()->getModelClassName('sales/order'));
$order->expects($this->once())->method('cancel');
$order->method('getId')->willReturn(-999);

/** @var Mollie_Mpm_Helper_data $instance */
$instance = Mage::helper('mpm');

$status = 'my custom status';
$order->expects($this->once())->method('addStatusHistoryComment')->with(
$instance->__('The order was canceled, reason: payment %s', $status)
);

$instance->registerCancellation($order, $status);
}
}
2 changes: 1 addition & 1 deletion app/code/community/Mollie/Mpm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<config>
<modules>
<Mollie_Mpm>
<version>5.5.3</version>
<version>5.5.4</version>
</Mollie_Mpm>
</modules>
<global>
Expand Down

0 comments on commit f3e6c8d

Please sign in to comment.