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';