6 use Koha::DateUtils qw( dt_from_string output_pref );
9 use Test::More tests => 7;
12 use_ok('C4::Circulation');
20 DeleteOfflineOperation
25 my $dbh = C4::Context->dbh;
26 $dbh->{RaiseError} = 1;
27 $dbh->{AutoCommit} = 0;
29 $dbh->do(q|DELETE FROM issues|);
30 $dbh->do(q|DELETE FROM borrowers|);
31 $dbh->do(q|DELETE FROM items|);
32 $dbh->do(q|DELETE FROM branches|);
33 $dbh->do(q|DELETE FROM pending_offline_operations|);
38 branchname => 'Sample Branch',
39 branchaddress1 => 'sample adr1',
40 branchaddress2 => 'sample adr2',
41 branchaddress3 => 'sample adr3',
42 branchzip => 'sample zip',
43 branchcity => 'sample city',
44 branchstate => 'sample state',
45 branchcountry => 'sample country',
46 branchphone => 'sample phone',
47 branchfax => 'sample fax',
48 branchemail => 'sample email',
49 branchurl => 'sample url',
50 branchip => 'sample ip',
51 branchprinter => undef,
52 opac_info => 'sample opac',
54 Koha::Library->new($samplebranch1)->store;
56 my $now = dt_from_string->truncate( to => 'minute' );
59 #Test AddOfflineOperation
62 'User1', $samplebranch1->{branchcode},
63 $now, 'Action1', 'CODE', 'Cardnumber1', 10
66 "OfflineOperation has been added"
69 $dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef );
71 #Test GetOfflineOperations
73 GetOfflineOperation($offline_id),
75 operationid => $offline_id,
77 branchcode => $samplebranch1->{branchcode},
78 # FIXME sounds like we need a 'timestamp' dateformat
79 timestamp => output_pref({ dt => $now, dateformat => 'iso', dateonly => 0 }) . ':00',
82 cardnumber => 'Cardnumber1',
85 "GetOffline returns offlineoperation's informations"
87 is( GetOfflineOperation(), undef,
88 'GetOfflineOperation without parameters returns undef' );
89 is( GetOfflineOperation(-1), undef,
90 'GetOfflineOperation with wrong parameters returns undef' );
92 #Test GetOfflineOperations
93 #TODO later: test GetOfflineOperations
94 # Actually we cannot mock C4::Context->userenv in unit tests
96 #Test DeleteOfflineOperation
97 is( DeleteOfflineOperation($offline_id),
98 'Deleted.', 'Offlineoperation has been deleted' );
100 #is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
101 #is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME