Bug 30888: Unit tests
Extending DelAuthority test in AuthoritiesMarc.t. Adding Koha/Authority.t for new method move_to_deleted. Test plan: Run both tests. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
ad45e5650b
commit
f7ed6981e1
2 changed files with 62 additions and 1 deletions
|
@ -366,7 +366,7 @@ subtest 'ModAuthority() tests' => sub {
|
|||
|
||||
subtest 'DelAuthority() tests' => sub {
|
||||
|
||||
plan tests => 2;
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -392,5 +392,8 @@ subtest 'DelAuthority() tests' => sub {
|
|||
undef,
|
||||
'skip_merge passed, merge not called';
|
||||
|
||||
# Check if last delete got moved to deletedauth_header
|
||||
isnt( Koha::Database->new->schema->resultset('DeletedauthHeader')->find($auth_id), undef, 'Moved to deleted' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
58
t/db_dependent/Koha/Authority.t
Executable file
58
t/db_dependent/Koha/Authority.t
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2024 Rijksmuseum, 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 => 1;
|
||||
|
||||
use C4::AuthoritiesMarc;
|
||||
use Koha::Authorities;
|
||||
use Koha::Database;
|
||||
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
my $schema = Koha::Database->new->schema;
|
||||
|
||||
subtest 'move_to_deleted' => sub {
|
||||
plan tests => 2;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); # TODO UNIMARC?
|
||||
|
||||
my $record = MARC::Record->new;
|
||||
$record->append_fields( MARC::Field->new( '100', '1', '2', a => 'Name' ) );
|
||||
my $type = $builder->build( { source => 'AuthType', value => { auth_tag_to_report => '100' } } );
|
||||
my $authid = C4::AuthoritiesMarc::AddAuthority(
|
||||
$record, undef,
|
||||
$type->{authtypecode}
|
||||
);
|
||||
my $authority = Koha::Authorities->find($authid);
|
||||
|
||||
# Trivial test to see if 'move' really copies..
|
||||
my $count = $schema->resultset('DeletedauthHeader')->count;
|
||||
my $rec = $authority->move_to_deleted;
|
||||
is( $schema->resultset('DeletedauthHeader')->count, $count + 1, 'count one higher' );
|
||||
|
||||
# Check leader position 05 in marcxml
|
||||
like( $rec->marcxml, qr/<leader>.{5}d/, 'Leader in marcxml checked' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
Loading…
Reference in a new issue