Commit ae271ed3 authored by Karamel's avatar Karamel
Browse files

Add a test for the old 8.0-8.6 desktop payment mode.

parent f82e4b38
......@@ -25,7 +25,10 @@ use \Pasteque\Server\Model\CashRegister;
use \Pasteque\Server\Model\CashSession;
use \Pasteque\Server\Model\CashSessionCat;
use \Pasteque\Server\Model\CashSessionCustBalance;
use \Pasteque\Server\Model\CashSessionPayment;
use \Pasteque\Server\Model\CashSessionTax;
use \Pasteque\Server\Model\Currency;
use \Pasteque\Server\Model\PaymentMode;
use \Pasteque\Server\Model\Tax;
use \Pasteque\Server\System\DateUtils;
use \Pasteque\Server\System\DAO\DAOFactory;
......@@ -51,6 +54,14 @@ class CashSessionTest extends TestCase
$this->tax2->setRate(0.2);
$this->dao->write($this->tax);
$this->dao->write($this->tax2);
$this->currency = new Currency();
$this->currency->setReference('currency');
$this->currency->setLabel('Currency');
$this->dao->write($this->currency);
$this->paymentMode = new PaymentMode();
$this->paymentMode->setReference('payment');
$this->paymentMode->setLabel('Payment');
$this->dao->write($this->paymentMode);
$this->dao->commit();
}
......@@ -65,6 +76,8 @@ class CashSessionTest extends TestCase
$this->dao->delete($this->cashRegister);
$this->dao->delete($this->tax);
$this->dao->delete($this->tax2);
$this->dao->delete($this->currency);
$this->dao->delete($this->paymentMode);
$this->dao->commit();
$this->dao->close();
}
......@@ -439,4 +452,16 @@ class CashSessionTest extends TestCase
$this->assertEquals(DateUtils::toTimestamp($date2), $struct['closeDate']);
}
/** Test the old format from Pasteque Desktop 8.0-8.6 which used hardcoded
* payment modes. */
public function testPaymentFromStructDesktopOld() {
$struct = ['amount' => 10, 'currencyAmount' => 12, 'cashSession' => null,
'currency' => $this->currency->getId()];
$struct['desktop'] = true;
$struct['type'] = $this->paymentMode->getReference();
$cashPayment = CashSessionPayment::fromStruct($struct, $this->dao);
$this->assertNotNull($cashPayment->getPaymentMode());
$this->assertEquals($this->paymentMode->getReference(),
$cashPayment->getPaymentMode()->getReference());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment