From 1d3d61e16fe8d784f7115b68db5e0f01ae5a5520 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 2 Jul 2009 16:01:03 +0000 Subject: [PATCH] Add hex generation code to tempspace Storage objects. Otherwise, they return undef. --- lib/WebGUI/Storage.pm | 2 +- t/Storage.t | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 8d5282244..99e3d47d1 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -617,7 +617,7 @@ sub createTemp { my $path = $session->id->toHex($id); $path =~ m/^(.{2})/; - my $self = {_session=>$session, _id => $id, _Hexid => $path, _pathParts => ['temp', $1, $path], _errors => []}; + my $self = {_session=>$session, _id => $id, _hexId => $path, _pathParts => ['temp', $1, $path], _errors => []}; bless $self, ref($class)||$class; $self->_makePath; return $self; diff --git a/t/Storage.t b/t/Storage.t index c288d0f07..d48a33432 100644 --- a/t/Storage.t +++ b/t/Storage.t @@ -29,7 +29,7 @@ my $cwd = Cwd::cwd(); my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session); -my $numTests = 103; # increment this value for each test you create +my $numTests = 107; # increment this value for each test you create plan tests => $numTests + scalar @{ $extensionTests } + scalar @{ $fileIconTests }; my $uploadDir = $session->config->get('uploadsPath'); @@ -150,7 +150,13 @@ $storage1 = WebGUI::Storage->create($session); isa_ok( $storage1, "WebGUI::Storage"); ok($session->id->valid($storage1->getId), 'create returns valid sessionIds'); -is($storage1->getHexId, $session->id->toHex($storage1->getId), 'getHexId, returns the hexadecimal value of the GUID'); +ok($storage1->getHexId, 'getHexId returns something'); +is($storage1->getHexId, $session->id->toHex($storage1->getId), '... returns the hexadecimal value of the GUID'); + +{ + my $otherStorage = WebGUI::Storage->get($session, $storage1->getId); + is($otherStorage->getHexId, $storage1->getHexId, '... works with get'); +} is( $storage1->getErrorCount, 0, "No errors during object creation"); @@ -286,15 +292,17 @@ ok(-e $hackedStore->getPath('fileToHack'), 'deleteFile did not delete the file i #################################################### # -# createTemp +# createTemp, getHexId # #################################################### my $tempStor = WebGUI::Storage->createTemp($session); isa_ok( $tempStor, "WebGUI::Storage", "createTemp creates WebGUI::Storage object"); -is (substr($tempStor->getPathFrag, 0, 5), 'temp/', 'createTemp puts stuff in the temp directory'); -ok (-e $tempStor->getPath(), 'createTemp: directory was created'); +is (substr($tempStor->getPathFrag, 0, 5), 'temp/', '... puts stuff in the temp directory'); +ok (-e $tempStor->getPath(), '... directory was created'); +ok($tempStor->getHexId, '... getHexId returns something'); +is($tempStor->getHexId, $session->id->toHex($tempStor->getId), '... returns the hexadecimal value of the GUID'); #################################################### #