1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
use constant TESTS => 22;
#===============================================================================
#
# FILE: 99workflow5.t
#
# DESCRIPTION: Tests the objects functionality in a workflow-style fashion.
# Greatly mimics elements from eMC.
#
# FILES: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Erik Hollensbe (), <erik@hollensbe.org>
# COMPANY:
# VERSION: 1.0
# CREATED: 01/15/2008 06:17:20 AM PST
# REVISION: $Id$
#===============================================================================
use strict;
use warnings;
use Test::More tests => TESTS; # see line 1
use CGI::ValidOp::Test;
use_ok('CGI::ValidOp');
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my $obj = init_obj_via_cgi_pm(
{
op => 'add',
'stuff[0][name]' => '123 Foobar',
'stuff[0][item]' => '8675309',
'stuff[0][number]' => 'Funkytown',
'stuff[0][shipping]' => 'PA',
'stuff[0][client_email]' => 'shorts@shorts.com',
'stuff[0][client]' => 'bob',
'stuff[0][no_client]' => 0,
},
$ops2
);
isa_ok($obj, 'CGI::ValidOp');
ok ($obj->objects('stuff'));
isa_ok($obj->objects('stuff')->[0], 'HASH');
is_deeply($obj->objects('stuff')->[0],
{
name => '123 Foobar',
item => '8675309',
number => 'Funkytown',
shipping => 'PA',
client => 'bob',
no_client => 0,
client_email => 'shorts@shorts.com',
}
);
SKIP: {
skip "no Loompa", 17 unless eval { require Loompa; 1 };
package Stuff;
our @ISA = qw(Loompa);
sub methods { [qw(name item number shipping client client_email no_client)] }
package main;
# test constructing an object
$obj = init_obj_via_cgi_pm(
{
op => 'add',
'stuff[0][name]' => '123 Foobar',
'stuff[0][item]' => '8675309',
'stuff[0][number]' => 'Funkytown',
'stuff[0][shipping]' => 'PA',
'stuff[0][client_email]' => 'shorts@shorts.com',
'stuff[0][client]' => 'bob',
'stuff[0][no_client]' => 0,
},
$ops3
);
isa_ok($obj, 'CGI::ValidOp');
ok($obj->objects('stuff'));
isa_ok($obj->objects('stuff')->[0], 'Stuff');
my $stuff = $obj->objects('stuff')->[0];
can_ok($stuff, 'name');
can_ok($stuff, 'number');
can_ok($stuff, 'item');
can_ok($stuff, 'shipping');
can_ok($stuff, 'client');
can_ok($stuff, 'client_email');
can_ok($stuff, 'no_client');
is($stuff->name, '123 Foobar');
is($stuff->item, '8675309');
is($stuff->number, 'Funkytown');
is($stuff->shipping, 'PA');
is($stuff->client, 'bob');
is($stuff->no_client, 0);
is($stuff->client_email, 'shorts@shorts.com');
}
|