Lines 1-67
Link Here
|
1 |
#!/usr/bin/env perl |
1 |
#!/usr/bin/env perl |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
# This file is part of Koha. |
4 |
|
4 |
# |
5 |
use Test::More tests => 6; |
5 |
# Copyright 2014 - Biblibre SARL |
6 |
use C4::Acquisition; |
6 |
# |
7 |
use C4::Biblio qw( AddBiblio DelBiblio ); |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
use C4::Bookseller; |
8 |
# under the terms of the GNU General Public License as published by |
9 |
use C4::Budgets; |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
use C4::Context; |
10 |
# (at your option) any later version. |
11 |
|
11 |
# |
12 |
# Start transaction |
12 |
# Koha is distributed in the hope that it will be useful, but |
13 |
my $dbh = C4::Context->dbh; |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
$dbh->{AutoCommit} = 0; |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
$dbh->{RaiseError} = 1; |
15 |
# GNU General Public License for more details. |
16 |
|
16 |
# |
17 |
$dbh->do(q{ |
17 |
# You should have received a copy of the GNU General Public License |
18 |
DELETE FROM aqorders; |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
}); |
|
|
20 |
|
19 |
|
21 |
my $booksellerid = C4::Bookseller::AddBookseller( |
20 |
use Modern::Perl; |
22 |
{ |
21 |
use Test::More tests => 7; |
23 |
name => "my vendor", |
22 |
use t::lib::TestBuilder; |
24 |
address1 => "bookseller's address", |
|
|
25 |
phone => "0123456", |
26 |
active => 1 |
27 |
} |
28 |
); |
29 |
|
30 |
my $basketno = C4::Acquisition::NewBasket( |
31 |
$booksellerid |
32 |
); |
33 |
|
23 |
|
34 |
my $budgetid = C4::Budgets::AddBudget( |
24 |
BEGIN { |
35 |
{ |
25 |
use_ok('C4::Acquisition'); |
36 |
budget_code => "budget_code_test_close_reopen", |
26 |
} |
37 |
budget_name => "budget_name_test_close_reopen", |
|
|
38 |
} |
39 |
); |
40 |
|
27 |
|
41 |
my $budget = C4::Budgets::GetBudget( $budgetid ); |
|
|
42 |
|
28 |
|
43 |
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); |
29 |
my $builder = t::lib::TestBuilder->new(); |
44 |
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); |
30 |
$builder->clear( { source => 'Aqorder' } ); |
45 |
|
31 |
|
46 |
my ($ordernumber1, $ordernumber2); |
32 |
my $order1 = $builder->build({ |
47 |
( undef, $ordernumber1 ) = C4::Acquisition::NewOrder( |
33 |
source => 'Aqorder', |
48 |
{ |
34 |
value => { |
49 |
basketno => $basketno, |
35 |
datecancellationprinted => undef, |
50 |
quantity => 24, |
36 |
}, |
51 |
biblionumber => $biblionumber1, |
37 |
only_fk => 1, |
52 |
budget_id => $budget->{budget_id}, |
38 |
}); |
53 |
} |
39 |
C4::Acquisition::NewOrder($order1); |
54 |
); |
|
|
55 |
|
40 |
|
56 |
( undef, $ordernumber2 ) = C4::Acquisition::NewOrder( |
41 |
my $order2 = $builder->build({ |
57 |
{ |
42 |
source => 'Aqorder', |
58 |
basketno => $basketno, |
43 |
value => { |
59 |
quantity => 42, |
44 |
basketno => $order1->{basketno}, |
60 |
biblionumber => $biblionumber2, |
45 |
datecancellationprinted => undef, |
61 |
budget_id => $budget->{budget_id}, |
46 |
}, |
62 |
} |
47 |
only_fk => 1, |
63 |
); |
48 |
}); |
|
|
49 |
C4::Acquisition::NewOrder($order2); |
64 |
|
50 |
|
|
|
51 |
my $basketno = $order1->{basketno}; |
65 |
my $nb_biblio = C4::Acquisition::GetBiblioCountByBasketno( $basketno ); |
52 |
my $nb_biblio = C4::Acquisition::GetBiblioCountByBasketno( $basketno ); |
66 |
is ( $nb_biblio, 2, "There are 2 biblio for this basket" ); |
53 |
is ( $nb_biblio, 2, "There are 2 biblio for this basket" ); |
67 |
my @orders = C4::Acquisition::GetOrders( $basketno ); |
54 |
my @orders = C4::Acquisition::GetOrders( $basketno ); |
Lines 76-80
C4::Acquisition::ReopenBasket( $basketno );
Link Here
|
76 |
@orders = C4::Acquisition::GetOrders( $basketno ); |
63 |
@orders = C4::Acquisition::GetOrders( $basketno ); |
77 |
is ( scalar( map { $_->{orderstatus} eq 'ordered' ? 1 : () } @orders ), 0, "No order are ordered, the basket is reopen" ); |
64 |
is ( scalar( map { $_->{orderstatus} eq 'ordered' ? 1 : () } @orders ), 0, "No order are ordered, the basket is reopen" ); |
78 |
is ( scalar( map { $_->{orderstatus} eq 'new' ? 1 : () } @orders ), 2, "2 orders are new, the basket is reopen" ); |
65 |
is ( scalar( map { $_->{orderstatus} eq 'new' ? 1 : () } @orders ), 2, "2 orders are new, the basket is reopen" ); |
79 |
|
|
|
80 |
$dbh->rollback; |
81 |
- |