From aec93573f02acbbf362bb73eac893c18543a2a96 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 14 Nov 2008 20:29:05 +0000 Subject: [PATCH] added test --- t/Account.t | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 t/Account.t diff --git a/t/Account.t b/t/Account.t new file mode 100644 index 000000000..7b67756d6 --- /dev/null +++ b/t/Account.t @@ -0,0 +1,76 @@ +# vim:syntax=perl +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------ +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------ + +# This tests the operation of WebGUI::Account modules. You can use +# as a base to test your own modules. + +use FindBin; +use strict; +use lib "$FindBin::Bin/lib"; +use Test::More; +use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Session; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; + + +#---------------------------------------------------------------------------- +# Tests + +plan tests => 7; # Increment this number for each test you create + +#---------------------------------------------------------------------------- +# Test the creation of WebGUI::Account + +# Can we load WebGUI::Account? +use_ok( "WebGUI::Account" ); + +SKIP: { # Not everyone has Test::Exception yet + eval { require Test::Exception; import Test::Exception }; + # Skip 1 test if Test::Exception couldn't be loaded + skip 1, 'Test::Exception not found' if $@; + throws_ok( sub { WebGUI::Account->new }, 'WebGUI::Error::InvalidObject', + 'new() throws exception without session object' + ); +}; + +my $account; +# ok() tests booleans. assignment evaluates to the value assigned (it's how '$a = $b = 4' works) +ok( $account = WebGUI::Account->new( $session ), + "WebGUI::Account object created successfully" +); + +# Test $account->isa +isa_ok( $account, "WebGUI::Account", 'Blessed into the right class' ); + +#---------------------------------------------------------------------------- +# Test getUrl + +is( $account->getUrl, $session->url->page('op=account;module=;do='), + 'getUrl adds op, module, and do' +); + +is( $account->getUrl( 'foo=bar' ), $session->url->page( 'op=account;foo=bar' ), + 'getUrl adds op if passed other parameters' +); + +is( $account->getUrl( 'op=account' ), $session->url->page( 'op=account' ), + 'getUrl doesnt add op=account if already exists' +); + +#---------------------------------------------------------------------------- +# Cleanup +END { + +} +#vim:ft=perl