Merge remote branch 'kc/new/enh/bug_4449' into kcmaster
[koha.git] / t / db_dependent / lib / KohaTest / Acquisition / GetParcel.pm
1 package KohaTest::Acquisition::GetParcel;
2 use base qw( KohaTest::Acquisition );
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8 use Time::localtime;
9
10 use C4::Acquisition;
11
12 =head3 no_parcel
13
14 at first, there should be no parcels for our bookseller.
15
16 =cut
17
18 sub no_parcel : Test( 1 ) {
19     my $self = shift;
20
21     my @parcel = GetParcel( $self->{'booksellerid'}, undef, undef );
22     is( scalar @parcel, 0, 'our new bookseller has no parcels' )
23       or diag( Data::Dumper->Dump( [ \@parcel ], [ 'parcel' ] ) );
24 }
25
26 =head3 one_parcel
27
28 we create an order, mark it as received, and then see if we can find
29 it with GetParcel.
30
31 =cut
32
33 sub one_parcel : Test( 17 ) {
34     my $self = shift;
35
36     my $invoice = 123;    # XXX what should this be?
37
38     my $today = sprintf( '%04d-%02d-%02d',
39                          localtime->year() + 1900,
40                          localtime->mon() + 1,
41                          localtime->mday() );
42     my ( $basketno, $ordernumber ) = $self->create_new_basket();
43     
44     ok( $basketno, "my basket number is $basketno" );
45     ok( $ordernumber,   "my order number is $ordernumber" );
46     my $datereceived = ModReceiveOrder( $self->{'biblios'}[0],             # biblionumber
47                                         $ordernumber,       # $ordernumber,
48                                         undef,         # $quantrec,
49                                         undef,         # $user,
50                                         undef,         # $cost,
51                                         $invoice,         # $invoiceno,
52                                         undef,         # $freight,
53                                         undef,         # $rrp,
54                                         $self->{'bookfundid'},         # $bookfund,
55                                         $today,         # $datereceived
56                                    );
57     is( $datereceived, $today, "the parcel was received on $datereceived" );
58
59     my @parcel = GetParcel( $self->{'booksellerid'}, $invoice, $today );
60     is( scalar @parcel, 1, 'we found one (1) parcel.' )
61       or diag( Data::Dumper->Dump( [ \@parcel ], [ 'parcel' ] ) );
62
63 }
64
65 1;