tests and such

This commit is contained in:
Doug Bell 2010-05-11 16:05:02 -05:00
parent 5c2581850f
commit e891410075
7 changed files with 254 additions and 3 deletions

86
t/Form/ButtonGroup.t Normal file
View file

@ -0,0 +1,86 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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
#------------------------------------------------------------------
# Test the ButtonGroup form element
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 6; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
use_ok( 'WebGUI::Form::ButtonGroup' );
#----------------------------------------------------------------------------
# buttons as params
my $bOne = WebGUI::Form::TestButton->new( $session, { name => "one" } );
my $bTwo = WebGUI::Form::TestButton->new( $session, { name => "two" } );
my $bg = WebGUI::Form::ButtonGroup->new( $session, {
buttons => [ $bOne, $bTwo ],
} );
cmp_deeply(
$bg->get('buttons'),
[ $bOne, $bTwo ],
"buttons is arrayref of objects",
);
#----------------------------------------------------------------------------
# addButton
my $bThree = $bg->addButton( "TestButton", { name => "three" } );
isa_ok( $bThree, 'WebGUI::Form::TestButton', 'addButton returns object' );
is( $bThree->get('name'), "three", 'addButton passes params to constructor' );
cmp_deeply(
$bg->get('buttons'),
[ $bOne, $bTwo, $bThree ],
"addButton adds button to list",
);
#----------------------------------------------------------------------------
# toHtml
my $html = $bg->toHtml;
like( $html, qr/onetwothree/, 'buttons rendered without extras between or around' );
#----------------------------------------------------------------------------
# Test collateral
package WebGUI::Form::TestButton;
# Fool WebGUI::Pluggable to prevent complaints
BEGIN { $INC{'WebGUI/Form/TestButton.pm'} = __FILE__ }
use base 'WebGUI::Form::Control';
sub toHtml {
return $_[0]->get('name');
}
#vim:ft=perl

40
t/Session/Cache.t Normal file
View file

@ -0,0 +1,40 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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
#------------------------------------------------------------------
# Test the CHI cache
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 1; # Increment this number for each test you create
my $cache = $session->cache;
isa_ok( $cache, "CHI::Driver" );
#----------------------------------------------------------------------------
# put your tests here
#vim:ft=perl

View file

@ -340,15 +340,26 @@ sub addRevision : Tests {
$newRevision->purgeRevision;
}
sub getEditForm : Tests {
note "getEditForm";
my ( $test ) = @_;
my $session = $test->session;
my ( $tag, $asset, @parents ) = $test->getAnchoredAsset();
}
sub www_editSave : Tests {
note "www_editSave";
my ( $test ) = @_;
my $session = $test->session;
my ( $tag, $asset, @parents ) = $test->getAnchoredAsset();
my $oldGroupId = $asset->groupIdEdit;
$asset->groupIdEdit( 7 ); # Everybody! Everybody!
$tag->setWorking;
$session->request->setup_body({
title => "Newly Saved Title",
} );
});
$asset->www_editSave;
# Get the newly-created revision of the asset
@ -356,6 +367,7 @@ sub www_editSave : Tests {
ok( $newRevision->tagId, 'new revision has a tag' );
is( $newRevision->tagId, $tag->getId, 'new revision tagId is current working tag' );
$asset->groupIdEdit( $oldGroupId );
}
1;