Koha/t/db_dependent/Illbatches.t
Pedro Amorim fc83fb3ebb
Bug 30719: (QA follow-up) Squash:
This is a squash of 25 QA patches located at:
    https://github.com/PTFS-Europe/koha/commits/new_30719

Bug 30719: (QA follow-up) Batch column should be hidden by default
Bug 30719: (QA follow-up) Fix wrong tt filter type
Bug 30719: (QA follow-up) Make atomicupdate idempotent
Bug 30719: (QA follow-up) Use COMMENT syntax in database files
Bug 30719: (QA follow-up) Fix tiny boolean is_system
Bug 30719: (QA follow-up) Add missing CONSTRAINT entries from kohastructure.sql to the atomicupdate file
Bug 30719: (QA follow-up) Add missing koha_object_class and
koha_objects_class methods
Bug 30719: (QA follow-up) Swap search to find
Bug 30719: (QA follow-up) Fix tests
Bug 30719: (QA follow-up) API terminology - id -> batch_id
Bug 30719: (QA follow-up) API terminology - borrowernumber -> patron_id
Bug 30719: (QA follow-up) API terminology - branchcode -> library_id
Bug 30719: (QA follow-up) Make mandatory illbatch_statuses translatable
Bug 30719: (QA follow-up) Improve translatability
Bug 30719: (QA follow-up) Fix capitalization of Interlibrary Loan
Bug 30719: (QA follow-up) Change Branch to Library in ILL batches table
Bug 30719: (QA follow-up) Add template WRAPPER to batch statuses breadrcrumbs
Bug 30719: (QA follow-up) Utilize patron_to_html function to display patron info in batches table
Bug 30719: (QA follow-up) Add mandatory batch statuses to the atomicupdate
Bug 30719: (QA follow-up) Add page-section to the batch statuses list page
Bug 30719: (QA follow-up) Style Save button on batch status edit page
Bug 30719: (QA follow-up) Add question mark to label string, rephrase new ILL batch button
Bug 30719: (QA follow-up) Add noExport class to action columns in batch list table and batch modal table
Bug 30719: (QA follow-up) Add page-section and headers to ILL batch table
Bug 30719: (QA follow-up) Perltidy

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-17 14:45:18 -03:00

98 lines
2.6 KiB
Perl
Executable file

#s!/usr/bin/perl
# 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 File::Basename qw/basename/;
use Koha::Database;
use Koha::Illbatch;
use Koha::Illbatches;
use Koha::Illrequests;
use Koha::Patrons;
use t::lib::Mocks;
use t::lib::TestBuilder;
use Test::MockObject;
use Test::MockModule;
use Test::More tests => 8;
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
use_ok('Koha::Illbatch');
use_ok('Koha::Illbatches');
$schema->storage->txn_begin;
Koha::Illrequests->search->delete;
# Create a patron
my $patron = $builder->build( { source => 'Borrower' } );
# Create a librarian
my $librarian = $builder->build(
{
source => 'Borrower',
value => { firstname => "Grogu" }
}
);
# Create a branch
my $branch = $builder->build( { source => 'Branch' } );
# Create a batch
my $illbatch = $builder->build(
{
source => 'Illbatch',
value => {
name => "My test batch",
backend => "Mock",
borrowernumber => $librarian->{borrowernumber},
branchcode => $branch->{branchcode}
}
}
);
my $batch_obj = Koha::Illbatches->find( $illbatch->{id} );
isa_ok( $batch_obj, 'Koha::Illbatch' );
# Create an ILL request in the batch
my $illrq = $builder->build(
{
source => 'Illrequest',
value => {
borrowernumber => $patron->{borrowernumber},
batch_id => $illbatch->{id}
}
}
);
my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} );
# Check requests_count
my $requests_count = $batch_obj->requests_count;
is( $requests_count, 1, 'requests_count returns correctly' );
# Check patron
my $batch_patron = $batch_obj->patron;
isa_ok( $batch_patron, 'Koha::Patron' );
is( $batch_patron->firstname, "Grogu", "patron returns correctly" );
# Check branch
my $batch_branch = $batch_obj->branch;
isa_ok( $batch_branch, 'Koha::Library' );
is( $batch_branch->branchcode, $branch->{branchcode}, "branch returns correctly" );
$illrq_obj->delete;
$schema->storage->txn_rollback;