-
Notifications
You must be signed in to change notification settings - Fork 11
/
history.t
48 lines (35 loc) · 1.21 KB
/
history.t
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
#!/usr/bin/env perl
use strict;
use lib qw(../lib lib ../t t);
use TestUtil;
use Test::More tests => 18;
require_ok( 'Workflow::History' );
my %params = (
workflow_id => 5,
action => 'An action',
description => 'A description',
user => 'Racer X',
state => 'TRANSIT',
date => DateTime->now(),
);
my $p_history = Workflow::History->new( \%params );
for ( keys %params ) {
is( $p_history->$_(), $params{ $_ },
"Parameter '$_' set properly from constructor" );
}
is( $p_history->is_saved, 0,
"Saved flag of new object unset" );
ok( ! $p_history->id,
"ID of new object unset" );
my $dt_history = Workflow::History->new();
ok( $dt_history->date->epoch + 10 > time,
'Current datetime set with new history object' );
my $history;
ok($history = Workflow::History->new({}), 'Constructing history object');
isa_ok($history, 'Workflow::History');
ok(! $history->is_saved(), 'Checking saved state');
ok($history->set_new_state('foo'), 'Setting state');
ok($history->set_saved(), 'Setting saved state');
ok($history->is_saved(), 'Checking saved state');
ok(! $history->clear_saved(), 'Unsetting saved state');
ok(! $history->is_saved(), 'Checking saved state');