Bug 15685: (QA follow-up) Improve Update DB entry + Add tests
DB revision fixes Unit tests Edit: fixed the update step description (tcohen) Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
bb57b47e0c
commit
5f511378c7
4 changed files with 63 additions and 2 deletions
11
installer/data/mysql/atomicupdate/bug15685.perl
Normal file
11
installer/data/mysql/atomicupdate/bug15685.perl
Normal file
|
@ -0,0 +1,11 @@
|
|||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
|
||||
$dbh->do(q{
|
||||
ALTER TABLE aqbasket
|
||||
ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL
|
||||
});
|
||||
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket)\n";
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE aqbasket ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') DEFAULT NULL;
|
|
@ -2992,7 +2992,7 @@ CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions
|
|||
`basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
|
||||
`deliveryplace` varchar(10) default NULL, -- basket delivery place
|
||||
`billingplace` varchar(10) default NULL, -- basket billing place
|
||||
create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL; -- when items should be created for orders in this basket
|
||||
create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL, -- when items should be created for orders in this basket
|
||||
branch varchar(10) default NULL, -- basket branch
|
||||
is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
|
||||
PRIMARY KEY (`basketno`),
|
||||
|
|
51
t/db_dependent/Koha/Acquisition/Basket.t
Normal file
51
t/db_dependent/Koha/Acquisition/Basket.t
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2017 Koha Development team
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 8;
|
||||
use Koha::Database;
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
use C4::Acquisition;
|
||||
|
||||
use_ok('Koha::Acquisition::Basket');
|
||||
use_ok('Koha::Acquisition::Baskets');
|
||||
|
||||
my $schema = Koha::Database->schema;
|
||||
$schema->storage->txn_begin;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# Start transaction
|
||||
$dbh->{RaiseError} = 1;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
my $basket = $builder->build_object({ class => 'Koha::Acquisition::Baskets', value => { create_items => undef } });
|
||||
my $created_basketno = C4::Acquisition::NewBasket($basket->booksellerid, $basket->authorisedby, $basket->basketname,$basket->note, $basket->booksellernote, $basket->contractnumber, $basket->deliveryplace, $basket->billingplace, $basket->is_standing, $basket->create_items);
|
||||
my $created_basket = Koha::Acquisition::Baskets->find({ basketno => $created_basketno });
|
||||
is($created_basket->basketno, $created_basketno, "Basket created by NewBasket matches db basket");
|
||||
is( $basket->create_items, undef, "Create items value can be null");
|
||||
t::lib::Mocks::mock_preference('AcqCreateItem', 'cataloguing');
|
||||
is( $basket->effective_create_items, "cataloguing","We use AcqCreateItem if basket create items is not set");
|
||||
C4::Acquisition::ModBasketHeader($basket->basketno, $basket->basketname, $basket->note, $basket->booksellernote, $basket->contractnumber, $basket->booksellerid, $basket->deliveryplace, $basket->billingplace, $basket->is_standing, "ordering");
|
||||
my $retrieved_basket = Koha::Acquisition::Baskets->find({ basketno => $basket->basketno });
|
||||
$basket->create_items("ordering");
|
||||
is( $retrieved_basket->create_items, "ordering", "Should be able to set with ModBasketHeader");
|
||||
is( $basket->create_items, "ordering", "Should be able to set with object methods");
|
||||
is_deeply($retrieved_basket->unblessed, $basket->unblessed, "Correct basket found and updated");
|
||||
is( $retrieved_basket->effective_create_items, "ordering","We use basket create items if it is set");
|
Loading…
Reference in a new issue