From 7299ba8f7ea74644fdaa7aaf502d2661941328bc Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 1 Jan 2008 03:07:49 +0000 Subject: [PATCH] add tests for getTitle and getMenuTitle --- t/Asset/Asset.t | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 40d3d4d42..8008c329a 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -30,6 +30,7 @@ my $session = WebGUI::Test->session; my @fixIdTests = getFixIdTests($session); my @fixTitleTests = getFixTitleTests($session); +my @getTitleTests = getTitleTests($session); my $rootAsset = WebGUI::Asset->getRoot($session); @@ -137,6 +138,7 @@ $canViewMaker->prepare( plan tests => 64 + scalar(@fixIdTests) + scalar(@fixTitleTests) + + 2*scalar(@getTitleTests) + $canAddMaker->plan + $canEditMaker->plan + $canViewMaker->plan @@ -317,6 +319,16 @@ my $properties2 = { my $fixTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id}); +$properties2 = { + # '1234567890123456789012' + id => 'getTitleAsset000000010', + title => '', + className => 'WebGUI::Asset::Snippet', + url => 'getTitleAsset1', +}; + +my $getTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id}); + $versionTag->commit; @@ -406,6 +418,25 @@ $fixTitleAsset->update({'title' => 0}); is($fixTitleAsset->fixTitle(''), 'Untitled', q{fixTitle: title is false, fixTitle returns 'Untitled'}); +################################################################ +# +# getTitle +# getMenuTitle +# +################################################################ + +my $getTitleAssetName = $getTitleAsset->getName(); + +foreach my $test (@getTitleTests) { + my $expectedTitle = $test->{assetName} ? $getTitleAssetName : $test->{title}; + $getTitleAsset->update({ + title => $test->{title}, + menuTitle => $test->{title}, + }); + is($getTitleAsset->getTitle, $expectedTitle, $test->{comment}); + is($getTitleAsset->getMenuTitle, $expectedTitle, $test->{comment}); +} + ################################################################ # # getIcon @@ -616,3 +647,37 @@ sub getFixTitleTests { }, ); } + +##Return an array of hashrefs. Each hashref describes a test +##for the getTitle and getMenuTitle tests. If "assetName" != 0, they +##will return the Asset's internationalized name. + +sub getTitleTests { + my $session = shift; + return ({ + title => undef, + assetName => 1, + comment => "getTitle: undef returns the Asset's name", + }, + { + title => '', + assetName => 1, + comment => "getTitle: null string returns the Asset's name", + }, + { + title => 'untitled', + assetName => 1, + comment => "getTitle: 'untitled' returns the Asset's name", + }, + { + title => 'UnTiTlEd', + assetName => 1, + comment => "getTitle: 'untitled' in any case returns the Asset's title", + }, + { + title => 'This is a good Title', + assetName => 0, + comment => "getTitle: Good titles are passed", + }, + ); +}