diff --git a/t/Asset/File/010-setfile.t b/t/Asset/File/010-setfile.t new file mode 100644 index 000000000..52e281b1c --- /dev/null +++ b/t/Asset/File/010-setfile.t @@ -0,0 +1,53 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../../../lib"; + +## The goal of this test is to test the creation and deletion of photo assets + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; +use WebGUI::Asset::File; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"File Test"}); +my $file + = $node->addChild({ + className => "WebGUI::Asset::File", + }); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} + +#---------------------------------------------------------------------------- +# Tests +plan tests => 0; + +#---------------------------------------------------------------------------- +# setFile allows file path argument and fails if can't find file + +#---------------------------------------------------------------------------- +# setFile allows filehandle argument, requires name argument and removes old +# file + + + + diff --git a/t/Asset/File/020-editSave.t b/t/Asset/File/020-editSave.t new file mode 100644 index 000000000..2f8956407 --- /dev/null +++ b/t/Asset/File/020-editSave.t @@ -0,0 +1,43 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../../../lib"; + +## The goal of this test is to test the correct function of the editSave and +# processPropertiesFromFormPost methods + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; +use WebGUI::Asset::File; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"File Test"}); +my $file + = $node->addChild({ + className => "WebGUI::Asset::File", + }); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} + +#---------------------------------------------------------------------------- +# Tests +plan tests => 0; diff --git a/t/Asset/File/Image/010-setfile.t b/t/Asset/File/Image/010-setfile.t new file mode 100644 index 000000000..48e8116e9 --- /dev/null +++ b/t/Asset/File/Image/010-setfile.t @@ -0,0 +1,48 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../../lib"; + +## The goal of this test is to test the additional functionality of the +# overridden setFile method + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; +use WebGUI::Asset::File::Image; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"Image Test"}); +my $image + = $node->addChild({ + className => "WebGUI::Asset::File::Image", + }); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} + +#---------------------------------------------------------------------------- +# Tests +plan tests => 0; + +#---------------------------------------------------------------------------- +# setFile also generates thumbnail + + diff --git a/t/Asset/File/Image/Photo/000-create-delete.t b/t/Asset/File/Image/Photo/000-create-delete.t new file mode 100644 index 000000000..5479ce664 --- /dev/null +++ b/t/Asset/File/Image/Photo/000-create-delete.t @@ -0,0 +1,76 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../../../lib"; + +## The goal of this test is to test the creation and deletion of photo assets + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"Photo Test"}); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} + +#---------------------------------------------------------------------------- +# Tests +plan tests => 5; + +#---------------------------------------------------------------------------- +# Test module compiles okay +# plan tests => 1 +use_ok("WebGUI::Asset::File::Image::Photo"); + +#---------------------------------------------------------------------------- +# Test creating a photo +# plan tests => 2 +my $photo + = $node->addChild({ + className => "WebGUI::Asset::File::Image::Photo", + }); + +is( + blessed $photo, "WebGUI::Asset::File::Image::Photo", + "Photo is a WebGUI::Asset::File::Image::Photo object", +); + +isa_ok( + $photo, "WebGUI::Asset::File::Image", +); + +#---------------------------------------------------------------------------- +# Test deleting a photo +# plan tests => 2 +my $properties = $photo->get; +$photo->purge; + +is( + $photo, undef + "Photo is undefined", +); + +is( + WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef, + "Photo no longer able to be instanciated", +); + diff --git a/t/Asset/File/Image/Photo/010-setfile.t b/t/Asset/File/Image/Photo/010-setfile.t new file mode 100644 index 000000000..145dce14e --- /dev/null +++ b/t/Asset/File/Image/Photo/010-setfile.t @@ -0,0 +1,47 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2007 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../../../../lib"; + +## The goal of this test is to test the creation and deletion of photo assets + +use Scalar::Util qw( blessed ); +use WebGUI::Test; +use WebGUI::Session; +use Test::More; +use WebGUI::Asset::File::Image::Photo; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; +my $node = WebGUI::Asset->getImportNode($session); +my $versionTag = WebGUI::VersionTag->getWorking($session); +$versionTag->set({name=>"Photo Test"}); +my $photo + = $node->addChild({ + className => "WebGUI::Asset::File::Image::Photo", + }); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} + +#---------------------------------------------------------------------------- +# Tests +plan tests => 0; + +#---------------------------------------------------------------------------- +# setFile also makes download versions + +