diff options
Diffstat (limited to 't')
-rw-r--r-- | t/02-number-handling.t | 31 | ||||
-rw-r--r-- | t/11-ledgersmb.t | 25 |
2 files changed, 54 insertions, 2 deletions
diff --git a/t/02-number-handling.t b/t/02-number-handling.t index 23eb7fee..b26ed7e4 100644 --- a/t/02-number-handling.t +++ b/t/02-number-handling.t @@ -156,11 +156,38 @@ is($form->format_amount({'numberformat' => '1000.00'} , '1.00', 2, 'x'), '1.00', is($lsmb->format_amount('user' => {'numberformat' => '1000.00'}, 'amount' => '1.00', 'precision' => 2, 'neg_format' => 'x'), '1.00', "lsmb: 1.00 with dash 'x'"); + +# Triggers the $amount .= "\.$dec" if ($dec ne ""); check to false is($form->format_amount({'numberformat' => '1000.00'} , '1.00'), '1', - "form: 1.00 with no precision or dash"); + "form: 1.00 with no precision or dash (1000.00)"); is($lsmb->format_amount('user' => {'numberformat' => '1000.00'}, 'amount' => '1.00'), '1', - "lsmb: 1.00 with no precision or dash"); + "lsmb: 1.00 with no precision or dash (1000.00)"); +is($form->format_amount({'numberformat' => '1,000.00'} , '1.00'), '1', + "form: 1.00 with no precision or dash (1,000.00)"); +is($lsmb->format_amount('user' => {'numberformat' => '1,000.00'}, + 'amount' => '1.00'), '1', + "lsmb: 1.00 with no precision or dash (1,000.00)"); +is($form->format_amount({'numberformat' => '1 000.00'} , '1.00'), '1', + "form: 1.00 with no precision or dash (1 000.00)"); +is($lsmb->format_amount('user' => {'numberformat' => '1 000.00'}, + 'amount' => '1.00'), '1', + "lsmb: 1.00 with no precision or dash (1 000.00)"); +is($form->format_amount({'numberformat' => '1\'000.00'} , '1.00'), '1', + "form: 1.00 with no precision or dash (1'000.00)"); +is($lsmb->format_amount('user' => {'numberformat' => '1\'000.00'}, + 'amount' => '1.00'), '1', + "lsmb: 1.00 with no precision or dash (1'000.00)"); +is($form->format_amount({'numberformat' => '1.000,00'} , '1,00'), '1', + "form: 1,00 with no precision or dash (1.000,00)"); +is($lsmb->format_amount('user' => {'numberformat' => '1.000,00'}, + 'amount' => '1,00'), '1', + "lsmb: 1,00 with no precision or dash (1.000,00)"); +is($form->format_amount({'numberformat' => '1000,00'} , '1,00'), '1', + "form: 1,00 with no precision or dash (1000,00)"); +is($lsmb->format_amount('user' => {'numberformat' => '1000,00'}, + 'amount' => '1,00'), '1', + "lsmb: 1,00 with no precision or dash (1000,00)"); is($form->format_amount({'numberformat' => '1000.00'} , '1.50'), '1.5', "form: 1.50 with no precision or dash"); is($lsmb->format_amount('user' => {'numberformat' => '1000.00'}, diff --git a/t/11-ledgersmb.t b/t/11-ledgersmb.t index 881ebc48..9ab8196f 100644 --- a/t/11-ledgersmb.t +++ b/t/11-ledgersmb.t @@ -249,3 +249,28 @@ is($lsmb->{apple}, 1, 'merge: No key, added apple'); is($lsmb->{pear}, 2, 'merge: No key, added pear'); is($lsmb->{peach}, 3, 'merge: No key, added peach'); like($lsmb->{path}, qr#bin/(lynx|mozilla)#, 'merge: No key, left existing key'); + +$lsmb = new LedgerSMB; +$lsmb->merge({'apple' => 1, 'pear' => 2, 'peach' => 3}, 'index' => 1); +is($lsmb->{apple_1}, 1, 'merge: Index 1, added apple as apple_1'); +is($lsmb->{pear_1}, 2, 'merge: Index 1, added pear as pear_1'); +is($lsmb->{peach_1}, 3, 'merge: Index 1, added peach as peach_1'); +like($lsmb->{path}, qr#bin/(lynx|mozilla)#, 'merge: Index 1, left existing key'); + +# $lsmb->is_allowed_role checks +$lsmb = new LedgerSMB; +$lsmb->{_roles} = ('apple', 'pear'); +is($lsmb->is_allowed_role('allowed_roles' => ['pear']), 1, + 'is_allowed_role: allowed role'); + +TODO: { + local $TODO = 'role system unimplemented'; + $lsmb->{_roles} = ['apple', 'pear']; + is($lsmb->is_allowed_role('allowed_roles' => ['peach']), 0, + 'is_allowed_role: disallowed role'); + is($lsmb->is_allowed_role('allowed_roles' => []), 0, + 'is_allowed_role: no allowable roles'); + delete $lsmb->{_roles}; + is($lsmb->is_allowed_role('allowed_roles' => ['apple']), 0, + 'is_allowed_role: no roles for user'); +} |