From ea7fe2650b401a411fbf5933dde4c2aed0c20147 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 26 Mar 2009 05:14:31 +0000 Subject: [PATCH] More tests for getUrl. Beginning of tests for canView. --- t/lib/Test/WebGUI/Account.pm | 27 +++++++++++++++++++++++++-- t/lib/Test/WebGUI/Account/Friends.pm | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/t/lib/Test/WebGUI/Account.pm b/t/lib/Test/WebGUI/Account.pm index de097d229..2f4cb8f38 100644 --- a/t/lib/Test/WebGUI/Account.pm +++ b/t/lib/Test/WebGUI/Account.pm @@ -36,7 +36,7 @@ sub __useItFirst : Test(startup) { $test->{_session} = $session; } -sub _new : Test(3) { +sub _new : Test(5) { my $test = shift; my $session = $test->{_session}; my $class = $test->class; @@ -49,9 +49,11 @@ sub _new : Test(3) { "$class object created successfully" ); isa_ok( $account, $class, 'Blessed into the right class' ); + is($account->uid, undef, 'new account objects have no uid'); + is($account->method, 'view', 'default method is view'); } -sub getUrl : Test(3) { +sub getUrl : Test(6) { my $test = shift; my $session = $test->{_session}; my $class = $test->class; @@ -68,6 +70,27 @@ sub getUrl : Test(3) { 'getUrl doesnt add op=account if already exists' ); + is( $account->getUrl('', 1), $session->url->page('op=account;module=;do='.$account->method), + 'getUrl does not add uid unless requested, unless uid is set' + ); + + $account->uid(3); + is( $account->getUrl, $session->url->page('op=account;module=;do='.$account->method), + 'getUrl does not add uid unless requested, even when set' + ); + + is( $account->getUrl('', 1), $session->url->page('op=account;module=;do='.$account->method.';uid=3'), + 'getUrl adds uid when requested, and uid is set' + ); + +} + +sub canView : Test(1) { + my $test = shift; + my $session = $test->{_session}; + my $class = $test->class; + my $account = $class->new($session); + is($account->canView(), 1, 'default canView is 1'); } 1; diff --git a/t/lib/Test/WebGUI/Account/Friends.pm b/t/lib/Test/WebGUI/Account/Friends.pm index 3d939fb5f..f7061807d 100644 --- a/t/lib/Test/WebGUI/Account/Friends.pm +++ b/t/lib/Test/WebGUI/Account/Friends.pm @@ -27,6 +27,11 @@ sub class { return 'WebGUI::Account::Friends'; } +sub canView : Test(1) { + local $TODO = 'Write tests for canView for Friends'; + ok(0,'Tests for canView for Friends'); +} + 1; #vim:ft=perl