Koha/t/db_dependent/Circulation/OfflineOperation.t
Jonathan Druart e28eaae983 Bug 12787: Reorganise t/db_dependent files
This patch tries to reorganise test files in the db_dependent directory:
- Circulation_Branch.t       has been moved to Circulation/Branch.t
- Circulation_issuingrules.t has been moved to Circulation/CalcDateDue.t
- Circulation_Issuingrule.t  has been moved to Circulation/GetHardDueDate.t
- Circulation_dateexpiry.t   has been moved to Circulation/dateexpiry.t
- Circulation_issue.t        has been moved to Circulation/issue.t
- Circulation_transfers.t    has been moved to Circulation/transfers.t
- Items_DelItem.t            has been moved to Items/DelItem.t
- BiblioObject.t             has been moved to Koha/Biblio.t
- Members_Attributes.t       has been moved to Members/Attributes.t
- Members_columns.t          has been moved to Members/columns.t
- Circulation_OfflineOperation.t   has been moved to Circulation/OfflineOperation.t
- Koha_template_plugin_KohaDates.t has been moved to Template/Plugin/KohaDates.t
- Koha_template_plugin_Branches.t  has been moved to Template/Plugin/Branches.t
- Reports/Guided.t, ReportsGuided.t and Reports_Guided.t have been
  merged

Test plan:
Confirm that all the modified tests still pass

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <bredan@bywatersolutions.com>
2016-04-22 00:54:35 +00:00

99 lines
2.6 KiB
Perl

#!/usr/bin/perl
use Modern::Perl;
use C4::Circulation;
use Koha::Library;
use Test::More tests => 7;
BEGIN {
use_ok('C4::Circulation');
}
can_ok(
'C4::Circulation',
qw(
AddOfflineOperation
GetOfflineOperation
GetOfflineOperations
DeleteOfflineOperation
)
);
#Start transaction
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM borrowers|);
$dbh->do(q|DELETE FROM items|);
$dbh->do(q|DELETE FROM branches|);
$dbh->do(q|DELETE FROM pending_offline_operations|);
#Add branch
my $samplebranch1 = {
branchcode => 'SAB1',
branchname => 'Sample Branch',
branchaddress1 => 'sample adr1',
branchaddress2 => 'sample adr2',
branchaddress3 => 'sample adr3',
branchzip => 'sample zip',
branchcity => 'sample city',
branchstate => 'sample state',
branchcountry => 'sample country',
branchphone => 'sample phone',
branchfax => 'sample fax',
branchemail => 'sample email',
branchurl => 'sample url',
branchip => 'sample ip',
branchprinter => undef,
opac_info => 'sample opac',
};
Koha::Library->new($samplebranch1)->store;
#Begin Tests
#Test AddOfflineOperation
is(
AddOfflineOperation(
'User1', $samplebranch1->{branchcode},
'null', 'Action1', 'CODE', 'Cardnumber1', 10
),
'Added.',
"OfflineOperation has been added"
);
my $offline_id =
$dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef );
#Test GetOfflineOperations
is_deeply(
GetOfflineOperation($offline_id),
{
operationid => $offline_id,
userid => 'User1',
branchcode => $samplebranch1->{branchcode},
timestamp => "0000-00-00 00:00:00",
action => 'Action1',
barcode => 'CODE',
cardnumber => 'Cardnumber1',
amount => '10.000000'
},
"GetOffline returns offlineoperation's informations"
);
is( GetOfflineOperation(), undef,
'GetOfflineOperation without parameters returns undef' );
is( GetOfflineOperation(-1), undef,
'GetOfflineOperation with wrong parameters returns undef' );
#Test GetOfflineOperations
#TODO later: test GetOfflineOperations
# Actually we cannot mock C4::Context->userenv in unit tests
#Test DeleteOfflineOperation
is( DeleteOfflineOperation($offline_id),
'Deleted.', 'Offlineoperation has been deleted' );
#is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
#is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
#End transaction
$dbh->rollback;