From 5a5a74964318234c5720968f77f2fdf099f45554 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 31 Dec 2007 04:45:07 +0000 Subject: [PATCH] Add tests for Asset->addMissing --- t/Asset/Asset.t | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 014af34fb..77eb9b99d 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -24,6 +24,7 @@ use WebGUI::VersionTag; use Test::More; use Test::MockObject; +use HTML::TokeParser; my $session = WebGUI::Test->session; @@ -133,7 +134,7 @@ $canViewMaker->prepare( }, ); -plan tests => 56 +plan tests => 59 + scalar(@fixIdTests) + scalar(@fixTitleTests) + $canAddMaker->plan @@ -454,6 +455,29 @@ $canEditMaker->run; $canViewMaker->run; +################################################################ +# +# addMissing +# +################################################################ + +$session->user({ userId => 3 }); +$session->var->switchAdminOff; +is($canEditAsset->addMissing('/nowhereMan'), undef, q{addMissing doesn't return anything unless use is in Admin Mode}); + +$session->var->switchAdminOn; +my $addMissing = $canEditAsset->addMissing('/nowhereMan'); +ok($addMissing, 'addMissing returns some output when in Admin Mode'); + +{ + + my $parser = HTML::TokeParser->new(\$addMissing); + my $link = $parser->get_tag('a'); + my $url = $link->[1]{'href'} || '-'; + like($url, qr{func=add;class=WebGUI::Asset::Wobject::Layout;url=/nowhereMan$}, 'addMissing: Link will add a new page asset with correct URL'); + +} + END: { $session->config->set('extrasURL', $origExtras); $session->config->set('uploadsURL', $origUploads);