added EMS Schedule table

This commit is contained in:
David Delikat 2009-05-20 02:51:44 +00:00
parent 8de4e6fed2
commit 0fb2b7775d
7 changed files with 411 additions and 4 deletions

View file

@ -19,6 +19,8 @@ use lib "$FindBin::Bin/../../lib";
use Test::More;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use JSON;
use Test::Deep;
#use Data::Dumper;
#----------------------------------------------------------------------------
@ -35,7 +37,7 @@ $versionTag->set({name=>"EventManagementSystem Test"});
#----------------------------------------------------------------------------
# Tests
plan tests => 22; # Increment this number for each test you create
plan tests => 30 ; # Increment this number for each test you create
#----------------------------------------------------------------------------
@ -132,8 +134,187 @@ ok($ems->can('getRibbons'), 'Can get ribbons');
my $ribbons = $ems->getRibbons;
ok(scalar(@$ribbons) == 2, 'Two ribbons exist');
#----------------------------------------------------------------------------
# Cleanup
ok( $ems->can('www_getScheduleDataJSON'), 'Can call get Schedule data' );
ok( $ems->can('www_viewSchedule'), 'Can call view Schedule' );
my $html = $ems->www_viewSchedule();
ok( $html !~ /REPLACE/, 'tags were successfully replaced');
# print 'html={', $html, "}\n";
my $data = $ems->www_getScheduleDataJSON();
cmp_deeply( JSON::from_json($data),
{
'totalPages' => 0,
'records' => [],
'pageSize' => 0,
'dir' => 'asc',
'recordsReturned' => 0,
'currentPage' => 0,
'sort' => undef,
'startIndex' => 0,
'totalRecords' => 0
},
'empty set: schedule data looks good' );
my @tickets= (
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 1 room a 10 am',
eventNumber => 1,
startDate => '2009-01-01 10:00:00',
location => 'a',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 2 room b 10 am',
eventNumber => 2,
startDate => '2009-01-01 10:00:00',
location => 'b',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 3 room c 10 am',
eventNumber => 3,
startDate => '2009-01-01 10:00:00',
location => 'c',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 4 room a 11 am',
eventNumber => 4,
startDate => '2009-01-01 11:00:00',
location => 'a',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 5 room b 11 am',
eventNumber => 5,
startDate => '2009-01-01 11:00:00',
location => 'b',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 6 room c 11 am',
eventNumber => 6,
startDate => '2009-01-01 11:00:00',
location => 'c',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 7 room d 12 am',
eventNumber => 7,
startDate => '2009-01-01 12:00:00',
location => 'd',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 8 room a 1 pm',
eventNumber => 8,
startDate => '2009-01-01 13:00:00',
location => 'a',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 9 room b 1 pm',
eventNumber => 9,
startDate => '2009-01-01 13:00:00',
location => 'b',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 10 room c 1 pm',
eventNumber => 10,
startDate => '2009-01-01 13:00:00',
location => 'c',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 11 room e 2 pm',
eventNumber => 11,
startDate => '2009-01-01 14:00:00',
location => 'e',
}),
$ems->addChild({
className => "WebGUI::Asset::Sku::EMSTicket",
title => 'lecture 12 room f 2 pm',
eventNumber => 12,
startDate => '2009-01-01 14:00:00',
location => 'f',
}),
);
is( scalar(@tickets), 12, 'created tickets for ems');
my $tickets = $ems->getTickets;
is(scalar(@$tickets), 14, 'Fourteen tickets exist');
my $locations = [ $ems->getLocations ];
cmp_deeply($locations, [ 'a','b','c','d','e','f' ], 'get locations returns all expected locations');
# print 'locations=[', join( ',', @$locations ),"]\n";
$data = $ems->www_getScheduleDataJSON();
# print 'json:',$data, "\n";
sub ticketInfo { my $tk = shift; return {
type => 'ticket',
title => $tk->get('title'),
assetId => $tk->get('assetId'),
description => $tk->get('description'),
location => $tk->get('location'),
startDate => $tk->get('startDate'),
}; }
cmp_deeply( JSON::from_json($data), {
records => [
{ colDate => '',
col1 => { type => 'label', title => 'a' },
col2 => { type => 'label', title => 'b' },
col3 => { type => 'label', title => 'c' },
col4 => { type => 'label', title => 'd' },
col5 => { type => 'label', title => 'e' },
},
{ colDate => $tickets[0]->get('startDate'),
col1 => ticketInfo( $tickets[0] ),
col2 => ticketInfo( $tickets[1] ),
col3 => ticketInfo( $tickets[2] ),
col4 => { type => 'empty' },
col5 => { type => 'empty' },
},
{ colDate => $tickets[3]->get('startDate'),
col1 => ticketInfo( $tickets[3] ),
col2 => ticketInfo( $tickets[4] ),
col3 => ticketInfo( $tickets[5] ),
col4 => { type => 'empty' },
col5 => { type => 'empty' },
},
{ colDate => $tickets[6]->get('startDate'),
col1 => { type => 'empty' },
col2 => { type => 'empty' },
col3 => { type => 'empty' },
col4 => ticketInfo( $tickets[6] ),
col5 => { type => 'empty' },
},
{ colDate => $tickets[7]->get('startDate'),
col1 => ticketInfo( $tickets[7] ),
col2 => ticketInfo( $tickets[8] ),
col3 => ticketInfo( $tickets[9] ),
col4 => { type => 'empty' },
col5 => { type => 'empty' },
},
{ colDate => $tickets[10]->get('startDate'),
col1 => { type => 'empty' },
col2 => { type => 'empty' },
col3 => { type => 'empty' },
col4 => { type => 'empty' },
col5 => ticketInfo( $tickets[10] ),
},
],
totalRecords => 6,
recordsReturned => 6,
startIndex => 0,
sort => undef,
dir => 'asc',
totalPages => 2,
pageSize => 10,
currentPage => 1,
rowsPerPage => 6,
},
'twelve tickets: schedule data looks good' );
#---------------------------------------------------------------------------# Cleanup
END {
$ems->purge;