Lines 19-25
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
21 |
|
21 |
|
22 |
use Test::More tests => 79; |
22 |
use Test::More tests => 65; |
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
use Koha::DateUtils qw(dt_from_string output_pref); |
25 |
use Koha::DateUtils qw(dt_from_string output_pref); |
Lines 292-298
for ( 0 .. 5 ) {
Link Here
|
292 |
$order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_]; |
292 |
$order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_]; |
293 |
} |
293 |
} |
294 |
|
294 |
|
295 |
DelOrder( $order_content[3]->{str}->{biblionumber}, $ordernumbers[3] ); |
295 |
Koha::Acquisition::Orders->find($ordernumbers[3])->cancel; |
296 |
|
296 |
|
297 |
my $invoiceid = AddInvoice( |
297 |
my $invoiceid = AddInvoice( |
298 |
invoicenumber => 'invoice', |
298 |
invoicenumber => 'invoice', |
Lines 527-566
is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is give
Link Here
|
527 |
$nonexistent_order = GetOrder( 424242424242 ); |
527 |
$nonexistent_order = GetOrder( 424242424242 ); |
528 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
528 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
529 |
|
529 |
|
530 |
# Tests for DelOrder |
|
|
531 |
$order1 = GetOrder($ordernumbers[0]); |
532 |
my $error = DelOrder($order1->{biblionumber}, $order1->{ordernumber}); |
533 |
ok((not defined $error), "DelOrder does not fail"); |
534 |
$order1 = GetOrder($order1->{ordernumber}); |
535 |
ok((defined $order1->{datecancellationprinted}), "order is cancelled"); |
536 |
ok((not defined $order1->{cancellationreason}), "order has no cancellation reason"); |
537 |
ok((defined Koha::Biblios->find( $order1->{biblionumber} )), "biblio still exists"); |
538 |
|
539 |
$order2 = GetOrder($ordernumbers[1]); |
540 |
$error = DelOrder($order2->{biblionumber}, $order2->{ordernumber}, 1); |
541 |
ok((not defined $error), "DelOrder does not fail"); |
542 |
$order2 = GetOrder($order2->{ordernumber}); |
543 |
ok((defined $order2->{datecancellationprinted}), "order is cancelled"); |
544 |
ok((not defined $order2->{cancellationreason}), "order has no cancellation reason"); |
545 |
ok((not defined Koha::Biblios->find( $order2->{biblionumber} )), "biblio does not exist anymore"); |
546 |
|
547 |
my $order4 = GetOrder($ordernumbers[3]); |
548 |
$error = DelOrder($order4->{biblionumber}, $order4->{ordernumber}, 1, "foobar"); |
549 |
ok((not defined $error), "DelOrder does not fail"); |
550 |
$order4 = GetOrder($order4->{ordernumber}); |
551 |
ok((defined $order4->{datecancellationprinted}), "order is cancelled"); |
552 |
ok(($order4->{cancellationreason} eq "foobar"), "order has cancellation reason \"foobar\""); |
553 |
ok((not defined Koha::Biblios->find( $order4->{biblionumber} )), "biblio does not exist anymore"); |
554 |
|
555 |
my $order5 = GetOrder($ordernumbers[4]); |
556 |
Koha::Item->new({ barcode => '0102030405', biblionumber => $order5->{biblionumber} })->store; |
557 |
$error = DelOrder($order5->{biblionumber}, $order5->{ordernumber}, 1); |
558 |
$order5 = GetOrder($order5->{ordernumber}); |
559 |
ok((defined $order5->{datecancellationprinted}), "order is cancelled"); |
560 |
ok((defined Koha::Biblios->find( $order5->{biblionumber} )), "biblio still exists"); |
561 |
|
562 |
# End of tests for DelOrder |
563 |
|
564 |
subtest 'ModOrder' => sub { |
530 |
subtest 'ModOrder' => sub { |
565 |
plan tests => 1; |
531 |
plan tests => 1; |
566 |
ModOrder( { ordernumber => $order1->{ordernumber}, unitprice => 42 } ); |
532 |
ModOrder( { ordernumber => $order1->{ordernumber}, unitprice => 42 } ); |
Lines 640-647
sub run_flavoured_tests {
Link Here
|
640 |
$orders = GetHistory( isbn => '0136019706' ); |
606 |
$orders = GetHistory( isbn => '0136019706' ); |
641 |
is( scalar(@$orders), 1, "GetHistory searches correctly by ISBN" ); |
607 |
is( scalar(@$orders), 1, "GetHistory searches correctly by ISBN" ); |
642 |
|
608 |
|
643 |
my $order = GetOrder($ordernumber); |
609 |
Koha::Acquisition::Orders->find($ordernumber)->cancel; |
644 |
DelOrder($order->{biblionumber}, $order->{ordernumber}, 1); |
|
|
645 |
} |
610 |
} |
646 |
|
611 |
|
647 |
# Do "flavoured" tests |
612 |
# Do "flavoured" tests |