merged from HEAD

This commit is contained in:
David Delikat 2009-03-25 14:45:27 +00:00
commit daf279f8d2
39 changed files with 1332 additions and 139 deletions

View file

@ -20,6 +20,7 @@ BEGIN {
$mocker->fake_new('WebGUI::Form::Image');
}
use File::Copy;
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Image;
@ -29,23 +30,23 @@ use WebGUI::Form::File;
use Test::More; # increment this value for each test you create
use Test::Deep;
plan tests => 7;
plan tests => 11;
my $session = WebGUI::Test->session;
my $square = WebGUI::Image->new($session, 100, 100);
$square->setBackgroundColor('#0000FF');
my $rectangle = WebGUI::Image->new($session, 100, 200);
$rectangle->setBackgroundColor('#0000FF');
##Create a storage location
my $storage = WebGUI::Storage->create($session);
##Save the image to the location
$square->saveToStorageLocation($storage, 'square.png');
$rectangle->saveToStorageLocation($storage, 'blue.png');
##Do a file existance check.
ok((-e $storage->getPath and -d $storage->getPath), 'Storage location created and is a directory');
cmp_bag($storage->getFiles, ['square.png'], 'Only 1 file in storage with correct name');
cmp_bag($storage->getFiles, ['blue.png'], 'Only 1 file in storage with correct name');
##Initialize an Image Asset with that filename and storage location
@ -68,9 +69,29 @@ is($asset->get('storageId'), $asset->getStorageLocation->getId, 'Image Asset sto
$asset->update({
storageId => $storage->getId,
filename => 'square.png',
filename => 'blue.png',
});
my $filename = $asset->getStorageLocation->getPath . "/" . $asset->get("filename");
my @stat_before = stat($filename);
$asset->getStorageLocation->rotate($asset->get("filename"), 90);
my @stat_after = stat($filename);
is(isnt_array(\@stat_before, \@stat_after), 1, 'Image is different after rotation');
@stat_before = stat($filename);
$asset->getStorageLocation->resize($asset->get("filename"), 200, 300);
my @stat_after = stat($filename);
is(isnt_array(\@stat_before, \@stat_after), 1, 'Image is different after resize');
@stat_before = stat($filename);
$asset->getStorageLocation->crop($asset->get("filename"), 100, 125, 10, 25);
my @stat_after = stat($filename);
is(isnt_array(\@stat_before, \@stat_after), 1, 'Image is different after crop');
my $sth = $session->db->read('describe imageAsset annotations');
isnt($sth->hashRef, undef, 'Annotations column is defined');
is($storage->getId, $asset->get('storageId'), 'Asset updated with correct new storageId');
is($storage->getId, $asset->getStorageLocation->getId, 'Cached Asset storage location updated with correct new storageId');
@ -81,3 +102,13 @@ END {
$versionTag->rollback;
}
}
sub isnt_array {
my ($a, $b) = @_;
for (my $i = 0; $i < @{ $a }; ++$i) {
return 1 if @{ $a }[$i] ne @{ $b }[$i];
}
return 0;
}

View file

@ -32,7 +32,7 @@ use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Wobject::Layout;
use Data::Dumper;
use Test::More tests => 4; # increment this value for each test you create
use Test::More tests => 8; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -60,6 +60,38 @@ ok(defined $collab->get('groupToEditPost'), 'groupToEditPost field is defined');
# Verify sane defaults
cmp_ok($collab->get('groupToEditPost'), 'eq', $collab->get('groupIdEdit'), 'groupToEditPost defaults to groupIdEdit correctly');
is($collab->get('rssCapableRssLimit'), 10, 'rssCapableRssLimit is set to the default');
# finally, add the post to the collaboration system
my $props = {
className => 'WebGUI::Asset::Post::Thread',
content => 'hello, world!',
};
my $post = $collab->addChild($props,
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Test for a sane object type
isa_ok($post, 'WebGUI::Asset::Post::Thread');
$props = {
className => 'WebGUI::Asset::Post::Thread',
content => 'jello, world!',
};
$post = $collab->addChild($props,
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $rssitems = $collab->getRssItems();
is($rssitems, 2, 'rssitems set to number of posts added');
is($collab->get('rssCapableRssLimit'), 10, 'rssCapableRssLimit is set to the default');
TODO: {
local $TODO = "Tests to make later";

View file

@ -74,7 +74,11 @@ $oldSettings{ specialState } = $session->setting->get( 'specialState' );
$session->setting->set( 'specialState', '' );
my ( $mech );
my $baseUrl = 'http://' . $session->config->get('sitename')->[0];
my $config_port;
if ($session->config->get('webServerPort')) {
$config_port = $session->config->get('webServerPort') || 80;
}
my $baseUrl = 'http://' . $session->config->get('sitename')->[0] . ":$config_port";
#----------------------------------------------------------------------------
# Tests

View file

@ -17,7 +17,7 @@ use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::PseudoRequest;
use Test::More tests => 16; # increment this value for each test you create
use Test::More tests => 17; # increment this value for each test you create
use Test::Deep;
use JSON;
use WebGUI::Asset::Wobject::Thingy;
@ -192,6 +192,14 @@ my ($fieldLabel, $columnType, $Null, $Key, $Default, $Extra) = $session->db->qui
is($fieldLabel,"field_".$fieldId,"A column for the new field Field_$fieldId exists.");
is($columnType,"longtext","The columns is the right type");
# Test duplicating a Thing
my $copyThingId = $thingy->duplicateThing($thingId);
$isValidId = $session->id->valid($copyThingId);
is($isValidId,1,"duplicating a Thing: duplicateThing returned a valid id: ".$copyThingId);
# Test adding, editing, getting and deleting thing data
my ($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'test value'});