Bug 14585: Fixing up online help on main page
[koha.git] / t / db_dependent / Circulation_OfflineOperation.t
blob2f5edf823554f9162a151747af63cbd68d6fcbef
1 #!/usr/bin/perl
3 use Modern::Perl;
4 use C4::Branch;
5 use C4::Circulation;
7 use Test::More tests => 7;
9 BEGIN {
10 use_ok('C4::Circulation');
12 can_ok(
13 'C4::Circulation',
14 qw(
15 AddOfflineOperation
16 GetOfflineOperation
17 GetOfflineOperations
18 DeleteOfflineOperation
22 #Start transaction
23 my $dbh = C4::Context->dbh;
24 $dbh->{RaiseError} = 1;
25 $dbh->{AutoCommit} = 0;
27 $dbh->do(q|DELETE FROM issues|);
28 $dbh->do(q|DELETE FROM borrowers|);
29 $dbh->do(q|DELETE FROM items|);
30 $dbh->do(q|DELETE FROM branches|);
31 $dbh->do(q|DELETE FROM pending_offline_operations|);
33 #Add branch
34 my $samplebranch1 = {
35 add => 1,
36 branchcode => 'SAB1',
37 branchname => 'Sample Branch',
38 branchaddress1 => 'sample adr1',
39 branchaddress2 => 'sample adr2',
40 branchaddress3 => 'sample adr3',
41 branchzip => 'sample zip',
42 branchcity => 'sample city',
43 branchstate => 'sample state',
44 branchcountry => 'sample country',
45 branchphone => 'sample phone',
46 branchfax => 'sample fax',
47 branchemail => 'sample email',
48 branchurl => 'sample url',
49 branchip => 'sample ip',
50 branchprinter => undef,
51 opac_info => 'sample opac',
53 ModBranch($samplebranch1);
55 #Begin Tests
56 #Test AddOfflineOperation
57 is(
58 AddOfflineOperation(
59 'User1', $samplebranch1->{branchcode},
60 'null', 'Action1', 'CODE', 'Cardnumber1', 10
62 'Added.',
63 "OfflineOperation has been added"
65 my $offline_id =
66 $dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef );
68 #Test GetOfflineOperations
69 is_deeply(
70 GetOfflineOperation($offline_id),
72 operationid => $offline_id,
73 userid => 'User1',
74 branchcode => $samplebranch1->{branchcode},
75 timestamp => "0000-00-00 00:00:00",
76 action => 'Action1',
77 barcode => 'CODE',
78 cardnumber => 'Cardnumber1',
79 amount => '10.000000'
81 "GetOffline returns offlineoperation's informations"
83 is( GetOfflineOperation(), undef,
84 'GetOfflineOperation without parameters returns undef' );
85 is( GetOfflineOperation(-1), undef,
86 'GetOfflineOperation with wrong parameters returns undef' );
88 #Test GetOfflineOperations
89 #TODO later: test GetOfflineOperations
90 # Actually we cannot mock C4::Context->userenv in unit tests
92 #Test DeleteOfflineOperation
93 is( DeleteOfflineOperation($offline_id),
94 'Deleted.', 'Offlineoperation has been deleted' );
96 #is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
97 #is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
99 #End transaction
100 $dbh->rollback;