From 3938f9ff0dddb8c1a0755c3576a8dd875b272031 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 22 Oct 2009 17:00:45 -0500 Subject: [PATCH] removed last remnants of old definition --- docs/migration.txt | 3 + lib/WebGUI/Asset.pm | 190 ++++++++++------------ lib/WebGUI/Asset/Wobject.pm | 3 - lib/WebGUI/Asset/Wobject/Collaboration.pm | 1 - lib/WebGUI/Asset/Wobject/StoryTopic.pm | 2 - lib/WebGUI/AssetBranch.pm | 8 +- lib/WebGUI/AssetPackage.pm | 2 +- lib/WebGUI/AssetTrash.pm | 4 +- lib/WebGUI/AssetVersioning.pm | 45 +++-- t/Asset/Asset.t | 170 +------------------ t/Asset/File.t | 2 +- 11 files changed, 121 insertions(+), 309 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index 7b88ba481..2177f82c2 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -79,4 +79,7 @@ assetExists - Simply instantiate the asset if you want to know if it exists. getValue - Use get() or the individual property accessors instead. +fixTitle - The title() method does what this used to do as the title is set. + +fixUrlFromParent - This functionality is built into fixUrl, so that all fixes happen and can't cause breakages. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 34aa7ac28..6f8c76baf 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -47,7 +47,6 @@ use WebGUI::Definition::Asset ( hoverHelp =>['99 description','Asset'], fieldType =>'text', defaultValue =>'Untitled', - filter =>'fixTitle', }, menuTitle=>{ tab =>"properties", @@ -55,7 +54,6 @@ use WebGUI::Definition::Asset ( hoverHelp =>['411 description','Asset'], uiLevel =>1, fieldType =>'text', - filter =>'fixTitle', defaultValue =>'Untitled', }, url=>{ @@ -64,8 +62,7 @@ use WebGUI::Definition::Asset ( hoverHelp =>['104 description','Asset'], uiLevel =>3, fieldType =>'text', - defaultValue =>'', - filter =>'fixUrl', + defaultValue => sub { return $_[0]->getId; }, }, isHidden=>{ tab =>"display", @@ -85,11 +82,7 @@ use WebGUI::Definition::Asset ( }, encryptPage=>{ fieldType => 'yesNo', - noFormPost => - sub { - my $self = shift; - return $self->session->config->get("sslEnabled"); - }, + noFormPost => sub { return $_[0]->session->config->get("sslEnabled"); }, tab => "security", label => ['encrypt page','Asset'], hoverHelp => ['encrypt page description','Asset'], @@ -102,7 +95,6 @@ use WebGUI::Definition::Asset ( hoverHelp =>['108 description','Asset'], uiLevel =>6, fieldType =>'user', - filter =>'fixId', defaultValue =>'3', }, groupIdView=>{ @@ -111,7 +103,6 @@ use WebGUI::Definition::Asset ( hoverHelp =>['872 description','Asset'], uiLevel =>6, fieldType =>'group', - filter =>'fixId', defaultValue =>'7', }, groupIdEdit=>{ @@ -121,7 +112,6 @@ use WebGUI::Definition::Asset ( hoverHelp =>['871 description','Asset'], uiLevel =>6, fieldType =>'group', - filter =>'fixId', defaultValue =>'4', }, synopsis=>{ @@ -502,58 +492,7 @@ sub DESTROY { #------------------------------------------------------------------- -=head2 fixId ( id, fieldName ) - -Returns the default Id for a field if we get an invalid Id, otherwise returns the id passed in. An valid id either looks like a GUID or is an integer. - -=head3 id - -The id to check. - -=head3 fieldName - -The name of the property we're checking. This is used to retrieve whatever the default is set to in the definition. - -=cut - -sub fixId { - my $self = shift; - my $id = shift; - my $field = shift; - if ($id =~ m/\A \d{1,22} \z/xms || $id =~ m/\A [A-Za-z0-9\-\_]{22} \z/xms) { - return $id; - } - return $self->getValue($field); -} - - -#------------------------------------------------------------------- - -=head2 fixTitle ( string ) - -Fixes a title by eliminating HTML from it. - -=head3 string - -Any text string. Most likely will have been the Asset's name or title. If -no string is supplied, then it will fetch the default title for the asset, -or the word Untitled. - -=cut - -sub fixTitle { - my $self = shift; - my $string = shift; - if (lc($string) eq "untitled" || $string eq "") { - $string = $self->getValue("title") || 'Untitled'; - } - return WebGUI::HTML::filter($string, 'all'); -} - - -#------------------------------------------------------------------- - -=head2 fixUrl ( url ) +=head2 fixUrl ( [value] ) Returns a URL, removing invalid characters and making it unique by adding a digit to the end if necessary. URLs are not allowed to be @@ -567,7 +506,7 @@ Assets have a maximum length of 250 characters. Any URL longer than URLs will be passed through $session->url->urlize to make them WebGUI compliant. That includes any languages specific constraints set up in the default language pack. -=head3 url +=head3 value Any text string. Most likely will have been the Asset's name or title. If the string is not passed in, then a url will be constructed from @@ -580,14 +519,19 @@ sub fixUrl { # build a URL from the parent unless ($url) { - $url = $self->getParent->get("url"); + $url = $self->getParent->url; $url =~ s/(.*)\..*/$1/; - $url .= '/'.$self->getValue("menuTitle"); + $url .= '/'.$self->menuTitle; } # if we're inheriting the URL from our parent, set that appropriately - if($self->get('inheritUrlFromParent')) { - $url = $self->fixUrlFromParent($url); + if ($self->inheritUrlFromParent) { + # if we're inheriting the URL from our parent, set that appropriately + my @parts = split(m{/}, $url); + # don't do anything unless we need to + if($url ne $self->getParent->get('url') . '/' . $parts[-1]) { + $url = $self->getParent->get('url') . '/' . $parts[-1]; + } } $url = $self->session->url->urlize($url); @@ -650,35 +594,6 @@ sub fixUrl { } -#------------------------------------------------------------------- - -=head2 fixUrlFromParent ( url ) - -URLs will be passed through $session->url->urlize to make them WebGUI compliant. -That includes any languages specific constraints set up in the default language pack. - -=head3 url - -Any text string. - -=cut - -sub fixUrlFromParent { - my $self = shift; - my $url = shift; - - # if we're inheriting the URL from our parent, set that appropriately - my @parts = split(m{/}, $url); - - # don't do anything unless we need to - if($url ne $self->getParent->get('url') . '/' . $parts[-1]) { - $url = $self->getParent->get('url') . '/' . $parts[-1]; - } - - return $url; -} - - #------------------------------------------------------------------- =head2 getAdminConsole ( ) @@ -1261,10 +1176,11 @@ Returns the title of this asset. If it's not specified or it's "Untitled" then t sub getTitle { my $self = shift; - if ($self->get("title") eq "" || lc($self->get("title")) eq "untitled") { + my $title = $self->title; + if ($title eq "" || lc($title) eq "untitled") { return $self->getName; } - return $self->get("title"); + return $title; } @@ -1431,9 +1347,9 @@ Name value pairs to add to the URL in the form of: sub getUrl { my $self = shift; my $params = shift; - my $url = $self->get("url"); + my $url = $self->url; $url = $self->session->url->gateway($url,$params); - if ($self->get("encryptPage")) { + if ($self->encryptPage) { $url = $self->session->url->getSiteURL().$url; $url =~ s/http:/https:/; } @@ -1526,6 +1442,29 @@ sub logView { #------------------------------------------------------------------- +=head2 menuTitle ( [value] ) + +Returns the menuTitle of the asset, which is used in navigations. + +=head3 value + +If specified this value will be used to set the title after it goes through some validation checking. + +=cut + +sub menuTitle { + my ($self, $title) = @_; + if (defined $title) { + if ($title eq "") { + $title = $self->title; + } + $title = WebGUI::HTML::filter($title, 'all'); + } + return $self->next::method($title); +} + +#------------------------------------------------------------------- + =head2 new ( session, assetId [, className, revisionDate ] ) Constructor. This does not create an asset. @@ -2231,6 +2170,30 @@ sub setSize { } +#------------------------------------------------------------------- + +=head2 title ( [value] ) + +Returns the title of the asset. + +=head3 value + +If specified this value will be used to set the title after it goes through some validation checking. + +=cut + +sub title { + my ($self, $title) = @_; + if (defined $title) { + if ($title eq "") { + $title = 'Untitled'; + } + $title = WebGUI::HTML::filter($title, 'all'); + } + return $self->next::method($title); +} + + #------------------------------------------------------------------- =head2 toggleToolbar ( ) @@ -2279,7 +2242,7 @@ sub update { ##If inheritUrlFromParent was sent, and it is true, then muck with the url ##The URL may have been sent too, so use it or the current Asset's URL. if (exists $properties->{inheritUrlFromParent} and $properties->{inheritUrlFromParent}) { - $properties->{'url'} = $self->fixUrlFromParent($properties->{'url'} || $self->get('url')); + $properties->{'url'} = $self->url($properties->{'url'} || $self->url); } # check the definition of all properties against what was given to us @@ -2343,6 +2306,27 @@ sub update { $self->purgeCache; } +#------------------------------------------------------------------- + +=head2 url ( [ value ] ) + +Returns the asset's url without any site specific prefixes. If you want a browser friendly url see the getUrl() method. + +=head3 value + +The new value to set the URL to. + +=cut + +sub url { + my ($self, $url) = @_; + if (defined $url) { + $url = $self->fixUrl($url); + } + return $self->next::method($url); +} + + #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index cbcc54ddd..c7ea17e5b 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -88,7 +88,6 @@ sub definition { tab=>"display", label=>$i18n->get(1073), hoverHelp=>$i18n->get('1073 description'), - filter=>'fixId', namespace=>'style' }, printableStyleTemplateId=>{ @@ -97,7 +96,6 @@ sub definition { tab=>"display", label=>$i18n->get(1079), hoverHelp=>$i18n->get('1079 description'), - filter=>'fixId', namespace=>'style' }, mobileStyleTemplateId => { @@ -106,7 +104,6 @@ sub definition { tab => 'display', label => $i18n->get('mobileStyleTemplateId label'), hoverHelp => $i18n->get('mobileStyleTemplateId description'), - filter => 'fixId', namespace => 'style', }, ); diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 867b58478..be8e286b8 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -905,7 +905,6 @@ sub definition { hoverHelp=>$i18n->get('group to edit hoverhelp'), uiLevel=>6, fieldType=>'group', - filter=>'fixId', defaultValue=>$groupIdEdit, # groupToEditPost should default to groupIdEdit }, postReceivedTemplateId =>{ diff --git a/lib/WebGUI/Asset/Wobject/StoryTopic.pm b/lib/WebGUI/Asset/Wobject/StoryTopic.pm index 48474ca3f..1b16f3955 100644 --- a/lib/WebGUI/Asset/Wobject/StoryTopic.pm +++ b/lib/WebGUI/Asset/Wobject/StoryTopic.pm @@ -59,7 +59,6 @@ sub definition { fieldType => 'template', label => $i18n->get('template'), hoverHelp => $i18n->get('template help'), - filter => 'fixId', namespace => 'StoryTopic', defaultValue => 'A16v-YjWAShXWvSACsraeg', }, @@ -68,7 +67,6 @@ sub definition { fieldType => 'template', label => $i18n->get('story template'), hoverHelp => $i18n->get('story template help'), - filter => 'fixId', namespace => 'Story', defaultValue => 'TbDcVLbbznPi0I0rxQf2CQ', }, diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index 6dd5dd746..3b6800c80 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -140,14 +140,14 @@ sub www_editBranch { -name=>"displayTitle", -label=>$i18n2->get(174), -hoverHelp=>$i18n2->get('174 description'), - -value=>$self->getValue("displayTitle"), + -value=>$self->get("displayTitle"), -uiLevel=>5, -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_displayTitle"}) ); $tabform->getTab("display")->template( -name=>"styleTemplateId", -label=>$i18n2->get(1073), - -value=>$self->getValue("styleTemplateId"), + -value=>$self->get("styleTemplateId"), -hoverHelp=>$i18n2->get('1073 description'), -namespace=>'style', -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_styleTemplateId"}) @@ -156,7 +156,7 @@ sub www_editBranch { -name=>"printableStyleTemplateId", -label=>$i18n2->get(1079), -hoverHelp=>$i18n2->get('1079 description'), - -value=>$self->getValue("printableStyleTemplateId"), + -value=>$self->get("printableStyleTemplateId"), -namespace=>'style', -subtext=>'
'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_printableStyleTemplateId"}) ); @@ -165,7 +165,7 @@ sub www_editBranch { name => 'mobileStyleTemplateId', label => $i18n2->get('mobileStyleTemplateId label'), hoverHelp => $i18n2->get('mobileStyleTemplateId description'), - value => $self->getValue('mobileStyleTemplateId'), + value => $self->get('mobileStyleTemplateId'), namespace => 'style', subtext => '
' . $i18n->get('change') . q{ } . WebGUI::Form::yesNo($self->session,{name=>"change_mobileStyleTemplateId"}), diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 6ead00258..3edb566f1 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -284,7 +284,7 @@ sub www_deployPackage { my $packageMasterAssetId = $self->session->form->param("assetId"); if (defined $packageMasterAssetId) { my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($self->session, $packageMasterAssetId); - unless ($packageMasterAsset->getValue('isPackage')) { #only deploy packages + unless ($packageMasterAsset->get('isPackage')) { #only deploy packages $self->session->errorHandler->security('deploy an asset as a package which was not set as a package.'); return undef; } diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index 6590bc591..f91ddda53 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -197,8 +197,8 @@ sub purge { $outputSub->($i18n->get('Clearing asset tables')); $session->db->beginTransaction; $session->db->write("delete from metaData_values where assetId = ?",[$self->getId]); - foreach my $definition (@{$self->definition($session)}) { - $session->db->write("delete from ".$definition->{tableName}." where assetId=?", [$self->getId]); + foreach my $table ($self->getTables) { + $session->db->write("delete from ".$table." where assetId=?", [$self->getId]); } $session->db->write("delete from asset where assetId=?", [$self->getId]); $session->db->commit; diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 5db3c4919..569147c1d 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -121,22 +121,19 @@ sub addRevision { ]); my %defaults = (); - foreach my $definition (@{$self->definition($self->session)}) { + # get the default values of each property + foreach my $property ($self->getProperties) { + my $defintion = $self->getProperty($property); + $defaults{$property} = $definition->{defaultValue}; + if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{serialize}) { + $defaults{$property} = $defaults{$property}->[0]; + } + } - # get the default values of each property - foreach my $property (keys %{$definition->{properties}}) { - $defaults{$property} = $definition->{properties}{$property}{defaultValue}; - if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{properties}{$property}{serialize}) { - $defaults{$property} = $defaults{$property}->[0]; - } - } - - # prime the tables - unless ($definition->{tableName} eq "assetData") { - $self->session->db->write( - "insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)", - [$self->getId, $now] - ); + # prime the tables + foreach my $table ($self->getTables) { + unless ($table eq "assetData") { + $self->session->db->write( "insert into ".$table." (assetId,revisionDate) values (?,?)", [$self->getId, $now]); } } $self->session->db->commit; @@ -356,18 +353,20 @@ Deletes a revision of an asset. If it's the last revision, it purges the asset a sub purgeRevision { my $self = shift; if ($self->getRevisionCount > 1) { - $self->session->db->beginTransaction; - foreach my $definition (@{$self->definition($self->session)}) { - $self->session->db->write("delete from ".$definition->{tableName}." where assetId=? and revisionDate=?",[$self->getId, $self->get("revisionDate")]); - } - my ($count) = $self->session->db->quickArray("select count(*) from assetData where assetId=? and status='pending'",[$self->getId]); + my $db = $self->session->db; + $db->beginTransaction; + foreach my $table ($self->getTables) { + $db->write("delete from ".$table." where assetId=? and revisionDate=?",[$self->getId, $self->get("revisionDate")]); + } + my $count = $db->quickScalar("select count(*) from assetData where assetId=? and status='pending'",[$self->getId]); if ($count < 1) { - $self->session->db->write("update asset set isLockedBy=null where assetId=?",[$self->getId]); + $db->write("update asset set isLockedBy=null where assetId=?",[$self->getId]); } - $self->session->db->commit; + $db->commit; $self->purgeCache; $self->updateHistory("purged revision ".$self->get("revisionDate")); - } else { + } + else { $self->purge; } } diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index c3342dff9..8187f9a4d 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -33,8 +33,6 @@ use Storable qw/dclone/; my $session = WebGUI::Test->session; -my @fixIdTests = getFixIdTests($session); -my @fixTitleTests = getFixTitleTests($session); my @getTitleTests = getTitleTests($session); my $rootAsset = WebGUI::Asset->getRoot($session); @@ -153,9 +151,7 @@ $canViewMaker->prepare( }, ); -plan tests => 116 - + scalar(@fixIdTests) - + scalar(@fixTitleTests) +plan tests => 112 + 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle + $canAddMaker->plan + $canAddMaker2->plan @@ -417,37 +413,6 @@ is($importNode->fixUrl('fixurl'), 'fixurl.html', 'Automatic adding of extensions is($importNode->fixUrl('fixurl.css'), 'fixurl.css', 'extensions aren\'t automatically added if there is already and extension'); $session->setting->set('urlExtension', undef); -################################################################ -# -# fixId -# -################################################################ - -my $ownerUserId = $importNode->getValue('ownerUserId'); - -foreach my $test (@fixIdTests) { - my $fixedId = $importNode->fixId($test->{id}, 'ownerUserId'); - my $expectedId = $test->{pass} ? $test->{id} : $ownerUserId; - is($fixedId, $expectedId, $test->{comment}); -} - -################################################################ -# -# fixTitle -# -################################################################ - -my $importNodeTitle = $importNode->getTitle(); - -foreach my $test (@fixTitleTests) { - my $fixedTitle = $importNode->fixTitle($test->{title}, 'ownerUserId'); - my $expectedTitle = defined $test->{fixed} ? $test->{fixed} : $importNodeTitle; - is($fixedTitle, $expectedTitle, $test->{comment}); -} - -$fixTitleAsset->update({'title' => 0}); - -is($fixTitleAsset->fixTitle(''), 'Untitled', q{fixTitle: title is false, fixTitle returns 'Untitled'}); ################################################################ # @@ -592,27 +557,6 @@ is($canEditAsset->getUiLevel, 8, 'getUiLevel: WebGUI::Asset has a configured ui is($fixTitleAsset->getUiLevel, 8, 'getUiLevel: Snippet has a configured uiLevel of 8'); -################################################################ -# -# assetExists -# -################################################################ - -{ - - my $id = $canViewAsset->getId; - my $class = 'WebGUI::Asset'; - my $date = $canViewAsset->get('revisionDate'); - - ok ( WebGUI::Asset->assetExists($session, $id, $class, $date), 'assetExists with proper class, id and revisionDate'); - ok (!WebGUI::Asset->assetExists($session, $id, 'WebGUI::Asset::Snippet', $date), 'assetExists with wrong class does not exist'); - my $id2 = $id; - ++$id2; - ok (!WebGUI::Asset->assetExists($session, $id2, $class, $date), 'assetExists with wrong id does not exist'); - ok (!WebGUI::Asset->assetExists($session, $id, $class, $date+1), 'assetExists with wrong revisionDate does not exist'); - -} - ################################################################ # # isValidRssItem @@ -892,118 +836,6 @@ $assetToCommit = $assetToCommit->cloneFromDb; is($assetToCommit->get('status'), 'approved', '... returns fresh, commited asset from the db'); ##Return an array of hashrefs. Each hashref describes a test -##for the fixId method. - -sub getFixIdTests { - my $session = shift; - return ( - { - id => '0', - pass => 1, - comment => 'digit zero', - }, - { - id => '1', - pass => 1, - comment => 'digit one', - }, - { - id => '123', - pass => 1, - comment => '3 digit integer', - }, - { - id => '12345678901'x2, - pass => 1, - comment => '22 digit integer', - }, - { - id => '12345678901'x4, - pass => 0, - comment => '44 digit integer', - }, - { - id => '', - pass => 0, - comment => 'null string is rejected', - }, - { - id => 'a', - pass => 0, - comment => 'single lower case character rejected', - }, - { - # '1234567890123456789012' - id => 'abc123ZYX098deadbeef()', - pass => 0, - comment => 'illegal characters in length 22 string rejected', - }, - { - id => $session->id->generate, - pass => 1, - comment => 'valid id accepted', - }, - ); -} - -##Return an array of hashrefs. Each hashref describes a test -##for the fixTitle method. If "fixed" != undef, it should -##contain what the fixTitle method will return. - -sub getFixTitleTests { - my $session = shift; - return ({ - title => undef, - fixed => undef, - comment => "undef returns the Asset's title", - }, - { - title => '', - fixed => undef, - comment => "null string returns the Asset's title", - }, - { - title => 'untitled', - fixed => undef, - comment => "'untitled' returns the Asset's title", - }, - { - title => 'UnTiTlEd', - fixed => undef, - comment => "'untitled' in any case returns the Asset's title", - }, - { - title => 'Username: ^@;', - fixed => 'Username: ^@;', - comment => "Macros are negated", - }, - { - title => 'A bold title', - fixed => 'A bold title', - comment => "Markup is stripped out", - }, - { - title => 'Javascript: ', - fixed => 'Javascript: ', - comment => "javascript removed", - }, - { - title => 'This is a good Title', - fixed => 'This is a good Title', - comment => "Good titles are passed", - }, - { - title => '', - fixed => '', - comment => "If there is no title left after processing, then it is set to untitled.", - }, - { - title => q|Quotes '"|, - fixed => q|Quotes '"|, - comment => "Quotes are not processed.", - }, - ); -} ##Return an array of hashrefs. Each hashref describes a test ##for the getTitle and getMenuTitle tests. If "assetName" != 0, they diff --git a/t/Asset/File.t b/t/Asset/File.t index c167a4a75..8276107d0 100644 --- a/t/Asset/File.t +++ b/t/Asset/File.t @@ -86,7 +86,7 @@ $versionTag->commit; my $fileStorage = WebGUI::Storage->create($session); my $guard2 = cleanupGuard($fileStorage); -$mocker->set_always('getValue', $fileStorage->getId); +$mocker->set_always('get', $fileStorage->getId); my $fileFormStorage = $asset->getStorageFromPost(); isa_ok($fileFormStorage, 'WebGUI::Storage', 'Asset::File::getStorageFromPost');