From a8b15f586f8f9e40e4941ac4148dca6705ce744c Mon Sep 17 00:00:00 2001 From: tetragon Date: Wed, 16 May 2007 23:22:22 +0000 Subject: More test coverage of LedgerSMB.pm and re-expression of round_amount git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1201 4979c152-3d1c-0410-bac9-87ea11338e46 --- t/11-ledgersmb.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 't/11-ledgersmb.t') 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'); +} -- cgit v1.2.3