3 # Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
5 # This file is part of Koha
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
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>.
22 use Test
::More tests
=> 4;
25 use Koha
::Acquisition
::Basket
;
26 use Koha
::Acquisition
::Baskets
;
27 use Koha
::Acquisition
::Bookseller
;
29 use t
::lib
::TestBuilder
;
31 my $schema = Koha
::Database
->new->schema;
32 $schema->storage->txn_begin;
34 my $builder = t
::lib
::TestBuilder
->new;
35 my $num_of_baskets = Koha
::Acquisition
::Baskets
->search->count;
37 my $bookseller = Koha
::Acquisition
::Bookseller
->new({
38 name
=> 'Bookseller1',
41 my $basket = Koha
::Acquisition
::Basket
->new({
42 basketname
=> 'Basket1',
43 booksellerid
=> $bookseller->id,
47 my $basket2 = Koha
::Acquisition
::Basket
->new({
48 basketname
=> 'BasketToDelete',
49 booksellerid
=> $bookseller->id,
53 like
( $basket->basketno, qr
|^\d
+$|, 'Adding a new basket should have set the basketno');
55 my $retrieved_basket = Koha
::Acquisition
::Baskets
->find( $basket->basketno );
56 is
( $retrieved_basket->basketname, $basket->basketname, 'Find a basket by id should return the correct basket' );
58 my $retrieved_bookseller = $retrieved_basket->bookseller;
59 is
( $retrieved_bookseller->name, $bookseller->name, "Finding the bookseller of a basket by the basket's booksellerid should work as expected" );
62 is
( Koha
::Acquisition
::Baskets
->search->count, $num_of_baskets + 1, 'Delete should have deleted the basket' );
64 $schema->storage->txn_rollback;