Bug 35588: Tidy up t/db_dependent/AuthorisedValues.t

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Julian Maurice 2023-12-22 14:18:12 +01:00 committed by Katrin Fischer
parent f53ebe874e
commit 002e02710b
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -165,14 +165,17 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v
Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'c', frameworkcode => 'ACQ', authorised_value => 'TEST', kohafield => 'items.location' } )->store; Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'c', frameworkcode => 'ACQ', authorised_value => 'TEST', kohafield => 'items.location' } )->store;
Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'd', frameworkcode => '', authorised_value => 'ANOTHER_4_TESTS', kohafield => 'items.another_field' } )->store; Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'd', frameworkcode => '', authorised_value => 'ANOTHER_4_TESTS', kohafield => 'items.another_field' } )->store;
Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => '5', frameworkcode => '', authorised_value => 'restricted_for_testing', kohafield => 'items.restricted' } )->store; Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => '5', frameworkcode => '', authorised_value => 'restricted_for_testing', kohafield => 'items.restricted' } )->store;
Koha::MarcSubfieldStructure->new( { tagfield => '003', frameworkcode => '', authorised_value => 'CONTROL_TEST', } )->store; Koha::MarcSubfieldStructure->new( { tagfield => '003', frameworkcode => '', authorised_value => 'CONTROL_TEST', } )
->store;
Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_1', lib => 'location_1' } )->store; Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_1', lib => 'location_1' } )->store;
Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_2', lib => 'location_2' } )->store; Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_2', lib => 'location_2' } )->store;
Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_3', lib => 'location_3' } )->store; Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_3', lib => 'location_3' } )->store;
Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'an_av' } )->store; Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'an_av' } )->store;
Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'another_av' } )->store; Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'another_av' } )->store;
Koha::AuthorisedValue->new( { category => 'CONTROL_TEST', authorised_value => 'lib1', lib => 'lib1' } )->store; Koha::AuthorisedValue->new( { category => 'CONTROL_TEST', authorised_value => 'lib1', lib => 'lib1' } )->store;
Koha::AuthorisedValue->new( { category => 'CONTROL_TEST', authorised_value => 'lib2', lib => 'lib2' } )->store; Koha::AuthorisedValue->new( { category => 'CONTROL_TEST', authorised_value => 'lib2', lib => 'lib2' } )->store;
subtest 'search_by_marc_field' => sub { subtest 'search_by_marc_field' => sub {
plan tests => 4; plan tests => 4;
my $avs; my $avs;
@ -262,8 +265,8 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v
subtest 'get_descriptions_by_marc_field' => sub { subtest 'get_descriptions_by_marc_field' => sub {
plan tests => 4; plan tests => 4;
my $control_descriptions = Koha::AuthorisedValues->get_descriptions_by_marc_field( my $control_descriptions =
{ frameworkcode => '', tagfield => '003', } ); Koha::AuthorisedValues->get_descriptions_by_marc_field( { frameworkcode => '', tagfield => '003', } );
is_deeply( is_deeply(
$control_descriptions, $control_descriptions,
{ {
@ -272,10 +275,13 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v
}, },
); );
my $control_descriptions_cached = Koha::AuthorisedValues->get_descriptions_by_marc_field( my $control_descriptions_cached =
{ frameworkcode => '', tagfield => '003', } ); Koha::AuthorisedValues->get_descriptions_by_marc_field( { frameworkcode => '', tagfield => '003', } );
is("$control_descriptions","$control_descriptions_cached","Same memory address used proves cached control desc data"); is(
"$control_descriptions", "$control_descriptions_cached",
"Same memory address used proves cached control desc data"
);
my $descriptions = Koha::AuthorisedValues->get_descriptions_by_marc_field( my $descriptions = Koha::AuthorisedValues->get_descriptions_by_marc_field(
{ frameworkcode => '', tagfield => '952', tagsubfield => 'c' } ); { frameworkcode => '', tagfield => '952', tagsubfield => 'c' } );