newByUrl should throw an exception. Test it.

This commit is contained in:
Colin Kuskie 2010-01-29 17:35:19 -08:00
parent 387866cfcb
commit 006570a05a
2 changed files with 26 additions and 8 deletions

View file

@ -35,7 +35,7 @@ my $session = WebGUI::Test->session;
my @getTitleTests = getTitleTests($session);
plan tests => 105
plan tests => 110
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
;
@ -139,6 +139,27 @@ note "newById";
);
}
note "newByUrl";
{
my $deadAsset = eval { WebGUI::Asset->newByUrl($session, '/workFromHomeScam'); };
my $e = Exception::Class->caught;
isa_ok($e, 'WebGUI::Error::ObjectNotFound');
cmp_deeply(
$e,
methods(
error => "The URL was requested, but does not exist in your asset tree.",
id => 'workfromhomescam',
),
'... checking error message',
);
my $root = eval { WebGUI::Asset->newByUrl($session, '/root'); };
isa_ok($root, 'WebGUI::Asset');
$root = eval { WebGUI::Asset->newByUrl($session, '/ROOT'); };
isa_ok($root, 'WebGUI::Asset');
$root = eval { WebGUI::Asset->newByUrl($session, '/root/'); };
isa_ok($root, 'WebGUI::Asset');
}
# -- no session
# Root Asset
my $rootAsset = WebGUI::Asset->getRoot($session);