Lines 1-71
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
# This file is part of Koha. |
4 |
|
4 |
# |
5 |
use Test::More; |
5 |
# Copyright 2014 - Biblibre SARL |
6 |
use C4::Acquisition; |
6 |
# |
7 |
use C4::Biblio; |
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 MARC::Record; |
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 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
|
19 |
|
17 |
my $booksellerid = C4::Bookseller::AddBookseller( |
20 |
use Modern::Perl; |
18 |
{ |
21 |
use Test::More tests => 4; |
19 |
name => "my vendor", |
22 |
use t::lib::TestBuilder; |
20 |
address1 => "bookseller's address", |
|
|
21 |
phone => "0123456", |
22 |
active => 1 |
23 |
} |
24 |
); |
25 |
|
23 |
|
26 |
my $basketno = C4::Acquisition::NewBasket( |
24 |
BEGIN { |
27 |
$booksellerid |
25 |
use_ok('C4::Acquisition'); |
28 |
); |
26 |
} |
29 |
|
27 |
|
30 |
my $budgetid = C4::Budgets::AddBudget( |
|
|
31 |
{ |
32 |
budget_code => "budget_code_test_getordersbybib", |
33 |
budget_name => "budget_name_test_getordersbybib", |
34 |
} |
35 |
); |
36 |
|
28 |
|
37 |
my $budget = C4::Budgets::GetBudget( $budgetid ); |
29 |
my $builder = t::lib::TestBuilder->new(); |
|
|
30 |
$builder->clear( { source => 'Aqorder' } ); |
38 |
|
31 |
|
39 |
my ($ordernumber1, $ordernumber2, $ordernumber3); |
32 |
my $order1 = $builder->build({ |
40 |
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, ''); |
33 |
source => 'Aqorder', |
41 |
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); |
34 |
value => { |
42 |
( undef, $ordernumber1 ) = C4::Acquisition::NewOrder( |
35 |
datecancellationprinted => undef, |
43 |
{ |
36 |
}, |
44 |
basketno => $basketno, |
37 |
only_fk => 1, |
45 |
quantity => 24, |
38 |
}); |
46 |
biblionumber => $biblionumber1, |
39 |
C4::Acquisition::NewOrder($order1); |
47 |
budget_id => $budget->{budget_id}, |
|
|
48 |
} |
49 |
); |
50 |
|
40 |
|
51 |
( undef, $ordernumber2 ) = C4::Acquisition::NewOrder( |
41 |
my $order2 = $builder->build({ |
52 |
{ |
42 |
source => 'Aqorder', |
53 |
basketno => $basketno, |
43 |
value => { |
54 |
quantity => 42, |
44 |
datecancellationprinted => undef, |
55 |
biblionumber => $biblionumber2, |
45 |
}, |
56 |
budget_id => $budget->{budget_id}, |
46 |
only_fk => 1, |
57 |
} |
47 |
}); |
58 |
); |
48 |
C4::Acquisition::NewOrder($order2); |
59 |
|
49 |
|
60 |
( undef, $ordernumber3 ) = C4::Acquisition::NewOrder( |
50 |
my $order3 = $builder->build({ |
61 |
{ |
51 |
source => 'Aqorder', |
62 |
basketno => $basketno, |
52 |
value => { |
63 |
quantity => 4, |
53 |
biblionumber => $order2->{biblionumber}, |
64 |
biblionumber => $biblionumber2, |
54 |
datecancellationprinted => undef, |
65 |
budget_id => $budget->{budget_id}, |
55 |
}, |
66 |
} |
56 |
only_fk => 1, |
67 |
); |
57 |
}); |
|
|
58 |
C4::Acquisition::NewOrder($order3); |
68 |
|
59 |
|
|
|
60 |
my $biblionumber1 = $order1->{biblionumber}; |
61 |
my $biblionumber2 = $order2->{biblionumber}; |
69 |
my @orders = GetOrdersByBiblionumber(); |
62 |
my @orders = GetOrdersByBiblionumber(); |
70 |
is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef'); |
63 |
is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef'); |
71 |
|
64 |
|
Lines 74-81
is(scalar(@orders), 1, '1 order on biblionumber 1');
Link Here
|
74 |
|
67 |
|
75 |
@orders = GetOrdersByBiblionumber( $biblionumber2 ); |
68 |
@orders = GetOrdersByBiblionumber( $biblionumber2 ); |
76 |
is(scalar(@orders), 2, '2 orders on biblionumber 2'); |
69 |
is(scalar(@orders), 2, '2 orders on biblionumber 2'); |
77 |
|
|
|
78 |
#End transaction |
79 |
$dbh->rollback; |
80 |
|
81 |
done_testing; |
82 |
- |