7 use Koha
::DateUtils
qw( dt_from_string output_pref );
10 use Test
::More tests
=> 7;
13 use_ok
('C4::Circulation');
21 DeleteOfflineOperation
25 my $schema = Koha
::Database
->new->schema;
26 $schema->storage->txn_begin;
27 my $dbh = C4
::Context
->dbh;
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 opac_info
=> 'sample opac',
53 Koha
::Library
->new($samplebranch1)->store;
55 my $now = dt_from_string
->truncate( to
=> 'minute' );
58 #Test AddOfflineOperation
61 'User1', $samplebranch1->{branchcode
},
62 $now, 'Action1', 'CODE', 'Cardnumber1', 10
65 "OfflineOperation has been added"
68 $dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef );
70 #Test GetOfflineOperations
72 GetOfflineOperation
($offline_id),
74 operationid
=> $offline_id,
76 branchcode
=> $samplebranch1->{branchcode
},
77 # FIXME sounds like we need a 'timestamp' dateformat
78 timestamp
=> output_pref
({ dt
=> $now, dateformat
=> 'iso', dateonly
=> 0 }) . ':00',
81 cardnumber
=> 'Cardnumber1',
84 "GetOffline returns offlineoperation's informations"
86 is
( GetOfflineOperation
(), undef,
87 'GetOfflineOperation without parameters returns undef' );
88 is
( GetOfflineOperation
(-1), undef,
89 'GetOfflineOperation with wrong parameters returns undef' );
91 #Test GetOfflineOperations
92 #TODO later: test GetOfflineOperations
93 # Actually we cannot mock C4::Context->userenv in unit tests
95 #Test DeleteOfflineOperation
96 is
( DeleteOfflineOperation
($offline_id),
97 'Deleted.', 'Offlineoperation has been deleted' );
99 #is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
100 #is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME