Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
package
money
Commits
998414e5
Commit
998414e5
authored
Aug 10, 2013
by
Thorsten Buss
Browse files
* remove varType currency cause string should possible also
* change test to USD (not DefaultValue)
parent
4a91238b
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Money/Money.php
View file @
998414e5
...
...
@@ -35,7 +35,7 @@ class Money
* @param bool $parseAmountAsMoneyString amount ist unit (not subuit) and in moneyformat (maybe , as dec_mark)
* @throws \Money\InvalidArgumentException
*/
public
function
__construct
(
$amount
,
Currency
$currency
=
null
,
$parseAmountAsMoneyString
=
false
)
public
function
__construct
(
$amount
,
$currency
=
null
,
$parseAmountAsMoneyString
=
false
)
{
if
(
!
is_int
(
$amount
)
&&
!
ctype_digit
(
$amount
))
{
// only numbers(int) - as string or int type
throw
new
InvalidArgumentException
(
"The first parameter of Money must be an integer. It's the amount, expressed in the smallest units of currency (eg cents)"
);
...
...
tests/Money/Tests/MoneyFormaterTest.php
View file @
998414e5
...
...
@@ -15,14 +15,14 @@ use Money\MoneyFormater;
class
MoneyFormaterTest
extends
MoneyTestCase
{
public
function
testFormater
()
{
$m
=
new
MoneyFormater
(
'
EUR
'
);
$this
->
assertEquals
(
'
€1.
234
,
56'
,
$m
->
format
(
123456
));
$this
->
assertEquals
(
'
€1.
234'
,
$m
->
format
(
123456
,
array
(
'no_cents'
=>
true
)));
$m
=
new
MoneyFormater
(
'
USD
'
);
$this
->
assertEquals
(
'
$1,
234
.
56'
,
$m
->
format
(
123456
));
$this
->
assertEquals
(
'
$1,
234'
,
$m
->
format
(
123456
,
array
(
'no_cents'
=>
true
)));
// with defaultParams
$m
=
new
MoneyFormater
(
'
EUR
'
,
array
(
'symbol'
=>
'~'
));
$this
->
assertEquals
(
'~1
.
234
,
56'
,
$m
->
format
(
123456
));
$this
->
assertEquals
(
'~1
.
234'
,
$m
->
format
(
123456
,
array
(
'no_cents'
=>
true
)));
$m
=
new
MoneyFormater
(
'
USD
'
,
array
(
'symbol'
=>
'~'
));
$this
->
assertEquals
(
'~1
,
234
.
56'
,
$m
->
format
(
123456
));
$this
->
assertEquals
(
'~1
,
234'
,
$m
->
format
(
123456
,
array
(
'no_cents'
=>
true
)));
}
public
function
testLegibly
()
{
...
...
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