Bug 15770: Do not format numbers if too big
[koha.git] / t / db_dependent / Circulation / OfflineOperation.t
blob387ae6427fac48b6cbf6b83d68abd3863512e51a
1 #!/usr/bin/perl
3 use Modern::Perl;
4 use C4::Circulation;
5 use Koha::Library;
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 branchcode => 'SAB1',
36 branchname => 'Sample Branch',
37 branchaddress1 => 'sample adr1',
38 branchaddress2 => 'sample adr2',
39 branchaddress3 => 'sample adr3',
40 branchzip => 'sample zip',
41 branchcity => 'sample city',
42 branchstate => 'sample state',
43 branchcountry => 'sample country',
44 branchphone => 'sample phone',
45 branchfax => 'sample fax',
46 branchemail => 'sample email',
47 branchurl => 'sample url',
48 branchip => 'sample ip',
49 branchprinter => undef,
50 opac_info => 'sample opac',
52 Koha::Library->new($samplebranch1)->store;
54 #Begin Tests
55 #Test AddOfflineOperation
56 is(
57 AddOfflineOperation(
58 'User1', $samplebranch1->{branchcode},
59 'null', 'Action1', 'CODE', 'Cardnumber1', 10
61 'Added.',
62 "OfflineOperation has been added"
64 my $offline_id =
65 $dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef );
67 #Test GetOfflineOperations
68 is_deeply(
69 GetOfflineOperation($offline_id),
71 operationid => $offline_id,
72 userid => 'User1',
73 branchcode => $samplebranch1->{branchcode},
74 timestamp => "0000-00-00 00:00:00",
75 action => 'Action1',
76 barcode => 'CODE',
77 cardnumber => 'Cardnumber1',
78 amount => '10.000000'
80 "GetOffline returns offlineoperation's informations"
82 is( GetOfflineOperation(), undef,
83 'GetOfflineOperation without parameters returns undef' );
84 is( GetOfflineOperation(-1), undef,
85 'GetOfflineOperation with wrong parameters returns undef' );
87 #Test GetOfflineOperations
88 #TODO later: test GetOfflineOperations
89 # Actually we cannot mock C4::Context->userenv in unit tests
91 #Test DeleteOfflineOperation
92 is( DeleteOfflineOperation($offline_id),
93 'Deleted.', 'Offlineoperation has been deleted' );
95 #is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
96 #is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
98 #End transaction
99 $dbh->rollback;