1 package KohaTest::Acquisition::GetHistory;
2 use base qw( KohaTest::Acquisition );
21 sub no_history : Test( 4 ) {
24 # my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on )
26 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory();
27 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
29 is( scalar @$order_loop, 0, 'order_loop is empty' );
30 is( $total_qty, 0, 'total_qty' );
31 is( $total_price, 0, 'total_price' );
32 is( $total_qtyreceived, 0, 'total_qtyreceived' );
41 sub one_order : Test( 50 ) {
44 my ( $basketno, $ordernumber ) = $self->create_new_basket();
45 ok( $basketno, "basketno is $basketno" );
46 ok( $ordernumber, "ordernumber is $ordernumber" );
48 # No arguments fetches no history.
50 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory();
51 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
53 is( scalar @$order_loop, 0, 'order_loop is empty' );
54 is( $total_qty, 0, 'total_qty' );
55 is( $total_price, 0, 'total_price' );
56 is( $total_qtyreceived, 0, 'total_qtyreceived' );
59 my $bibliodata = GetBiblioData( $self->{'biblios'}[0] );
60 ok( $bibliodata->{'title'}, 'the biblio has a title' )
61 or diag( Data::Dumper->Dump( [ $bibliodata ], [ 'bibliodata' ] ) );
63 # searching by title should find it.
65 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $bibliodata->{'title'} );
66 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
68 is( scalar @$order_loop, 1, 'order_loop searched by title' );
69 is( $total_qty, 1, 'total_qty searched by title' );
70 is( $total_price, 1, 'total_price searched by title' );
71 is( $total_qtyreceived, 0, 'total_qtyreceived searched by title' );
73 # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
78 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, $bibliodata->{'author'} );
79 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
81 is( scalar @$order_loop, 1, 'order_loop searched by author' );
82 is( $total_qty, 1, 'total_qty searched by author' );
83 is( $total_price, 1, 'total_price searched by author' );
84 is( $total_qtyreceived, 0, 'total_qtyreceived searched by author' );
89 # diag( Data::Dumper->Dump( [ $bibliodata ], [ 'bibliodata' ] ) );
91 my $bookseller = GetBookSellerFromId( $self->{'booksellerid'} );
92 ok( $bookseller->{'name'}, 'bookseller name' )
93 or diag( Data::Dumper->Dump( [ $bookseller ], [ 'bookseller' ] ) );
95 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, $bookseller->{'name'} );
96 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
98 is( scalar @$order_loop, 1, 'order_loop searched by name' );
99 is( $total_qty, 1, 'total_qty searched by name' );
100 is( $total_price, 1, 'total_price searched by name' );
101 is( $total_qtyreceived, 0, 'total_qtyreceived searched by name' );
104 # searching by from_date
106 my $tomorrow = $self->tomorrow();
107 # diag( "tomorrow is $tomorrow" );
109 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, undef, undef, $tomorrow );
110 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
112 is( scalar @$order_loop, 1, 'order_loop searched by to_date' );
113 is( $total_qty, 1, 'total_qty searched by to_date' );
114 is( $total_price, 1, 'total_price searched by to_date' );
115 is( $total_qtyreceived, 0, 'total_qtyreceived searched by to_date' );
118 # searching by from_date
120 my $yesterday = $self->yesterday();
121 # diag( "yesterday was $yesterday" );
123 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( undef, undef, undef, $yesterday );
124 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
126 is( scalar @$order_loop, 1, 'order_loop searched by from_date' );
127 is( $total_qty, 1, 'total_qty searched by from_date' );
128 is( $total_price, 1, 'total_price searched by from_date' );
129 is( $total_qtyreceived, 0, 'total_qtyreceived searched by from_date' );
132 # set up some things necessary to make GetHistory use the IndependantBranches
133 $self->enable_independant_branches();
135 # just search by title here, we need to search by something.
137 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $bibliodata->{'title'} );
138 # diag( Data::Dumper->Dump( [ $order_loop, $total_qty, $total_price, $total_qtyreceived ], [ qw( order_loop total_qty total_price total_qtyreceived ) ] ) );
140 is( scalar @$order_loop, 1, 'order_loop searched by title' );
141 is( $total_qty, 1, 'total_qty searched by title' );
142 is( $total_price, 1, 'total_price searched by title' );
143 is( $total_qtyreceived, 0, 'total_qtyreceived searched by title' );
145 # diag( Data::Dumper->Dump( [ $order_loop ], [ 'order_loop' ] ) );
149 $self->disable_independant_branches();