App-Dochazka-Common
view release on metacpan or search on metacpan
t/model/reset.t view on Meta::CPAN
code => 'NOT_A_CODE',
intvl => '("1553-02-21 00:15","1557-06-13 17:45")',
long_desc => 'not really very long',
remark => 'let this one pass',
partial => 0,
},
'Lock' => {
lid => undef,
eid => 22,
intvl => '("1653-02-21 00:15","1657-06-13 17:45")',
remark => 'bazblat',
},
'Privhistory' => {
phid => undef,
eid => 4434,
priv => 'passerby',
effective => 'someday',
remark => 'that\'s not a timestamptz!',
},
'Schedhistory' => {
shid => undef,
eid => 44,
sid => 93432,
scode => 'ORC',
effective => 'some year',
remark => 'that\'s not a paparazzi!',
},
'Schedule' => {
sid => undef,
scode => 'GUINEA_PIG',
schedule => "This is definitely NOT a guinea pig",
remark => "sure it is",
disabled => 1,
},
);
foreach my $cl (
'Activity',
'Component',
'Employee',
'Interval',
'Lock',
'Privhistory',
'Schedhistory',
'Schedule',
) {
my $full_class = 'App::Dochazka::Common::Model::' . $cl;
note( "Looping: $full_class" );
note( 'attempt to spawn a hooligan' );
like( exception { $full_class->spawn( 'hooligan' => 'sneaking in' ); },
qr/not listed in the validation options: hooligan/ );
note('spawn testing object' );
my $testobj = $full_class->spawn( %{ $props_dispatch{$cl} } );
note( 'reset it' );
$testobj->reset;
note( 'verify that we have all the properties right' );
foreach my $prop ( @{ $full_class->attrs } ) {
note( "Property $prop" );
ok( exists( $props_dispatch{$cl}->{$prop} ) );
}
my %attrs;
map { $attrs{$_} = ''; } @{ $full_class->attrs };
foreach my $prop ( keys( %{ $props_dispatch{$cl} } ) ) {
ok( exists( $attrs{$prop} ) );
}
note( 'verify that all properties have been set to undef' );
foreach my $prop ( @{ $full_class->attrs } ) {
is( $testobj->{$prop}, undef );
}
}
done_testing;
( run in 0.468 second using v1.01-cache-2.11-cpan-13bb782fe5a )