From 1e7a6a1e53eadbd46133507f9e5f1cceb760f550 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Oct 2025 15:34:36 +0200 Subject: [PATCH] Bug 40777: Add tests for nonexistent_AV --- .../Koha/Database/DataInconsistency.t | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Database/DataInconsistency.t b/t/db_dependent/Koha/Database/DataInconsistency.t index c5c47b76f75..445ee4ea7b1 100755 --- a/t/db_dependent/Koha/Database/DataInconsistency.t +++ b/t/db_dependent/Koha/Database/DataInconsistency.t @@ -1,7 +1,7 @@ use Modern::Perl; #use Test::NoWarnings; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Warn; use Koha::Items; @@ -369,3 +369,30 @@ subtest 'errors_in_marc' => sub { $schema->storage->txn_rollback(); }; + +subtest 'nonexistent_AV' => sub { + + plan tests => 2; + + $schema->storage->txn_begin(); + + my $biblio_ok = $builder->build_sample_biblio; + my $item_ok = $builder->build_sample_item( { biblionumber => $biblio_ok->biblionumber } ); + my $biblio_ko = $builder->build_sample_biblio; + my $item_ko = $builder->build_sample_item( { biblionumber => $biblio_ko->biblionumber } ); + + my $biblios = Koha::Biblios->search( { biblionumber => [ $biblio_ok->biblionumber, $biblio_ko->biblionumber ] } ); + + subtest 'ok' => sub { + plan tests => 1; + my @errors = Koha::Database::DataInconsistency->nonexistent_AV($biblios); + is_deeply( \@errors, [] ); + }; + + subtest 'ccode not an AV' => sub { + plan tests => 1; + $item_ko->set( { withdrawn => -1 } )->store; + my @errors = Koha::Database::DataInconsistency->nonexistent_AV($biblios); + is( scalar(@errors), 1 ); + }; +}; -- 2.34.1