add a bunch of tests
This commit is contained in:
parent
a2c75c64b9
commit
fad056cfa5
5 changed files with 267 additions and 0 deletions
53
t/Asset/File/010-setfile.t
Normal file
53
t/Asset/File/010-setfile.t
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
43
t/Asset/File/020-editSave.t
Normal file
43
t/Asset/File/020-editSave.t
Normal file
|
|
@ -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;
|
||||||
48
t/Asset/File/Image/010-setfile.t
Normal file
48
t/Asset/File/Image/010-setfile.t
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
76
t/Asset/File/Image/Photo/000-create-delete.t
Normal file
76
t/Asset/File/Image/Photo/000-create-delete.t
Normal file
|
|
@ -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",
|
||||||
|
);
|
||||||
|
|
||||||
47
t/Asset/File/Image/Photo/010-setfile.t
Normal file
47
t/Asset/File/Image/Photo/010-setfile.t
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue