#!/usr/bin/perl use strict; use warnings; use Math::BigInt; use Test::More tests => 12; use Test::Exception; # We need the Rekening and Actief classes use src::bo::Passief; # we test the passief account my $passief = Passief->new("kapitaal"); is( ref $passief, "Passief", "A passief object" ); is( $passief->getName(), "kapitaal", "It's kapitaal" ); lives_ok { $passief->addToAccount() } "addToAccount is overwritten"; $passief->addToAccount( Math::BigInt->new(5) ); is( $passief->getDebetAmount(), Math::BigInt->new(5), "kapitaal has 5 credit" ); is( ref $passief->getDebetAmount(), "Math::BigInt", "getCreditAmount() returns a BigInt" ); lives_ok { $passief->subtractFromAccount() } "subtractFromAccount is overwritten"; $passief->subtractFromAccount( Math::BigInt->new(4) ); is( $passief->getCreditAmount(), Math::BigInt->new(4), "kapitaal has 4 debet" ); is( ref $passief->getCreditAmount(), "Math::BigInt", "getDebetAmount() returns a BigInt" ); is( $passief->balance(), 1, "kapitaal has a 1 balance" ); is( ref $passief->balance(), "Math::BigInt", "balance() returns a BigInt" ); # we test if we can call setCreditAmount directly throws_ok { $passief->setCreditAmount(0) } qr/setCreditAmount is protected/, "setCreditAmount is protected"; # we test if we can call setDebetAmount directly throws_ok { $passief->setDebetAmount(0) } qr/setDebetAmount is protected/, "setDebetAmount is protected";