From cd08debd111c90f6848645be2ba9b4e12153551a Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 5 Sep 2017 03:31:54 +0000 Subject: [PATCH] Bug 13208: [FOLLOW-UP] Tests for Koha::Acquisition::Baskets To test: prove -v t/db_dependent/Koha/Acquisition/Baskets.t Signed-off-by: David Bourgault https://bugs.koha-community.org/show_bug.cgi?id=18584 --- t/db_dependent/Koha/Acquisition/Baskets.t | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 t/db_dependent/Koha/Acquisition/Baskets.t diff --git a/t/db_dependent/Koha/Acquisition/Baskets.t b/t/db_dependent/Koha/Acquisition/Baskets.t new file mode 100644 index 0000000..45076f5 --- /dev/null +++ b/t/db_dependent/Koha/Acquisition/Baskets.t @@ -0,0 +1,65 @@ +#!/usr/bin/perl + +# Copyright 2017 Aleisha Amohia +# +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More tests => 4; + +use Koha::Database; +use Koha::Acquisition::Basket; +use Koha::Acquisition::Baskets; +use Koha::Acquisition::Bookseller; + +use t::lib::TestBuilder; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; + +my $builder = t::lib::TestBuilder->new; +my $num_of_baskets = Koha::Acquisition::Baskets->search->count; + +my $bookseller = Koha::Acquisition::Bookseller->new({ + name => 'Bookseller1', + currency => 'USD', +})->store; + +my $basket = Koha::Acquisition::Basket->new({ + basketname => 'Basket1', + booksellerid => $bookseller->id, + is_standing => 0, +})->store; + +my $basket2 = Koha::Acquisition::Basket->new({ + basketname => 'BasketToDelete', + booksellerid => $bookseller->id, + is_standing => 0, +})->store; + +like( $basket->basketno, qr|^\d+$|, 'Adding a new basket should have set the basketno'); + +my $retrieved_basket = Koha::Acquisition::Baskets->find( $basket->basketno ); +is( $retrieved_basket->basketname, $basket->basketname, 'Find a basket by id should return the correct basket' ); + +my $retrieved_bookseller = $retrieved_basket->bookseller; +is( $retrieved_bookseller->name, $bookseller->name, "Finding the bookseller of a basket by the basket's booksellerid should work as expected" ); + +$basket2->delete; +is( Koha::Acquisition::Baskets->search->count, $num_of_baskets + 1, 'Delete should have deleted the basket' ); + +$schema->storage->txn_rollback; -- 2.7.4