Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pasteque
pasteque-server
Commits
ae271ed3
Commit
ae271ed3
authored
Jan 09, 2020
by
Karamel
Browse files
Add a test for the old 8.0-8.6 desktop payment mode.
parent
f82e4b38
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/Model/CashSessionTest.php
View file @
ae271ed3
...
...
@@ -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
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment