From 1c05a2aa500c602f77e84e346c07d82fcdfd7723 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 May 2022 11:29:57 +0200 Subject: [PATCH] Bug 30870: Don't skip tests if Test::Deep if not installed We are using Test::Deep in different tests, but from t/db_dependent/Koha.t the tests are skippted if the module is not installed. We must assume the module is installed Test plan: prove t/db_dependent/Koha.t should return green in ktd Signed-off-by: David Nind --- t/db_dependent/Koha.t | 183 +++++++++++++++++++++--------------------- 1 file changed, 90 insertions(+), 93 deletions(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 36f1b08b55..f57d09588e 100755 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -6,6 +6,7 @@ use Modern::Perl; use Test::More tests => 5; use Test::Warn; +use Test::Deep; use t::lib::TestBuilder; @@ -58,101 +59,97 @@ subtest 'Authorized Values Tests' => sub { $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); } - SKIP: { - eval { require Test::Deep; import Test::Deep; }; - skip "Test::Deep required to run the GetAuthorisedValues() tests.", 2 if $@; - Koha::AuthorisedValueCategory->new({ category_name => 'BUG10656' })->store; - Koha::AuthorisedValue->new( - { category => 'BUG10656', - authorised_value => 'ZZZ', - lib => 'Z_STAFF', - lib_opac => 'A_PUBLIC', - imageurl => '' - } - )->store; - Koha::AuthorisedValue->new( - { category => 'BUG10656', + Koha::AuthorisedValueCategory->new({ category_name => 'BUG10656' })->store; + Koha::AuthorisedValue->new( + { category => 'BUG10656', + authorised_value => 'ZZZ', + lib => 'Z_STAFF', + lib_opac => 'A_PUBLIC', + imageurl => '' + } + )->store; + Koha::AuthorisedValue->new( + { category => 'BUG10656', + authorised_value => 'AAA', + lib => 'A_STAFF', + lib_opac => 'Z_PUBLIC', + imageurl => '' + } + )->store; + + # the next one sets lib_opac to NULL; in that case, the staff + # display value is meant to be used. + Koha::AuthorisedValue->new( + { category => 'BUG10656', + authorised_value => 'DDD', + lib => 'D_STAFF', + lib_opac => undef, + imageurl => '' + } + )->store; + + my $authvals = GetAuthorisedValues('BUG10656'); + cmp_deeply( + $authvals, + [ + { + id => ignore(), + category => 'BUG10656', authorised_value => 'AAA', - lib => 'A_STAFF', - lib_opac => 'Z_PUBLIC', - imageurl => '' - } - )->store; - - # the next one sets lib_opac to NULL; in that case, the staff - # display value is meant to be used. - Koha::AuthorisedValue->new( - { category => 'BUG10656', + lib => 'A_STAFF', + lib_opac => 'Z_PUBLIC', + imageurl => '', + }, + { + id => ignore(), + category => 'BUG10656', authorised_value => 'DDD', - lib => 'D_STAFF', - lib_opac => undef, - imageurl => '' - } - )->store; - - my $authvals = GetAuthorisedValues('BUG10656'); - cmp_deeply( - $authvals, - [ - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'AAA', - lib => 'A_STAFF', - lib_opac => 'Z_PUBLIC', - imageurl => '', - }, - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'DDD', - lib => 'D_STAFF', - lib_opac => undef, - imageurl => '', - }, - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'ZZZ', - lib => 'Z_STAFF', - lib_opac => 'A_PUBLIC', - imageurl => '', - }, - ], - 'list of authorised values in staff mode sorted by staff label (bug 10656)' - ); - $authvals = GetAuthorisedValues('BUG10656', 1); - cmp_deeply( - $authvals, - [ - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'ZZZ', - lib => 'A_PUBLIC', - lib_opac => 'A_PUBLIC', - imageurl => '', - }, - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'DDD', - lib => 'D_STAFF', - lib_opac => undef, - imageurl => '', - }, - { - id => ignore(), - category => 'BUG10656', - authorised_value => 'AAA', - lib => 'Z_PUBLIC', - lib_opac => 'Z_PUBLIC', - imageurl => '', - }, - ], - 'list of authorised values in OPAC mode sorted by OPAC label (bug 10656)' - ); - } + lib => 'D_STAFF', + lib_opac => undef, + imageurl => '', + }, + { + id => ignore(), + category => 'BUG10656', + authorised_value => 'ZZZ', + lib => 'Z_STAFF', + lib_opac => 'A_PUBLIC', + imageurl => '', + }, + ], + 'list of authorised values in staff mode sorted by staff label (bug 10656)' + ); + $authvals = GetAuthorisedValues('BUG10656', 1); + cmp_deeply( + $authvals, + [ + { + id => ignore(), + category => 'BUG10656', + authorised_value => 'ZZZ', + lib => 'A_PUBLIC', + lib_opac => 'A_PUBLIC', + imageurl => '', + }, + { + id => ignore(), + category => 'BUG10656', + authorised_value => 'DDD', + lib => 'D_STAFF', + lib_opac => undef, + imageurl => '', + }, + { + id => ignore(), + category => 'BUG10656', + authorised_value => 'AAA', + lib => 'Z_PUBLIC', + lib_opac => 'Z_PUBLIC', + imageurl => '', + }, + ], + 'list of authorised values in OPAC mode sorted by OPAC label (bug 10656)' + ); warning_is { GetAuthorisedValues() } [], 'No warning when no parameter passed to GetAuthorisedValues'; -- 2.30.2