From 3bdb5d21a4461e305750764b922010bd013fe387 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 14 Mar 2023 14:49:19 +0000 Subject: [PATCH] Bug 33214: (RMaint follow-up) Remove tests for unbackported feature We haven't backport the strings_map functionality, so we don't need the fixes to the tests for it here. Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Item.t | 203 ------------------------------------- 1 file changed, 203 deletions(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 46f359a69d..59f11313e2 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -1448,209 +1448,6 @@ subtest 'columns_to_str' => sub { $schema->storage->txn_rollback; }; -subtest 'strings_map() tests' => sub { - - plan tests => 6; - - $schema->storage->txn_begin; - - my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber"); - - my $cache = Koha::Caches->get_instance(); - $cache->clear_from_cache("MarcStructure-0-"); - $cache->clear_from_cache("MarcStructure-1-"); - $cache->clear_from_cache("MarcSubfieldStructure-"); - $cache->clear_from_cache("libraries:name"); - $cache->clear_from_cache("itemtype:description:en"); - $cache->clear_from_cache("cn_sources:description"); - $cache->clear_from_cache("AV_descriptions:LOST"); - - # Recreating subfields just to be sure tests will be ok - # 1 => av (LOST) - # 3 => no link - # a => branches - # y => itemtypes - Koha::MarcSubfieldStructures->search( - { - frameworkcode => '', - tagfield => $itemtag, - tagsubfield => [ '1', '2', '3', 'a', 'y' ], - } - )->delete; # In case it exist already - - Koha::MarcSubfieldStructure->new( - { - authorised_value => 'LOST', - defaultvalue => '', - frameworkcode => '', - kohafield => 'items.itemlost', - repeatable => 1, - tab => 10, - tagfield => $itemtag, - tagsubfield => '1', - } - )->store; - Koha::MarcSubfieldStructure->new( - { - authorised_value => 'cn_source', - defaultvalue => '', - frameworkcode => '', - kohafield => 'items.cn_source', - repeatable => 1, - tab => 10, - tagfield => $itemtag, - tagsubfield => '2', - } - )->store; - Koha::MarcSubfieldStructure->new( - { - authorised_value => '', - defaultvalue => '', - frameworkcode => '', - kohafield => 'items.materials', - repeatable => 1, - tab => 10, - tagfield => $itemtag, - tagsubfield => '3', - } - )->store; - Koha::MarcSubfieldStructure->new( - { - authorised_value => 'branches', - defaultvalue => '', - frameworkcode => '', - kohafield => 'items.homebranch', - repeatable => 1, - tab => 10, - tagfield => $itemtag, - tagsubfield => 'a', - } - )->store; - Koha::MarcSubfieldStructure->new( - { - authorised_value => 'itemtypes', - defaultvalue => '', - frameworkcode => '', - kohafield => 'items.itype', - repeatable => 1, - tab => 10, - tagfield => $itemtag, - tagsubfield => 'y', - } - )->store; - - my $itype = $builder->build_object( { class => 'Koha::ItemTypes' } ); - my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $biblio = $builder->build_sample_biblio( { frameworkcode => '' } ); - my $item = $builder->build_sample_item( - { - biblionumber => $biblio->id, - library => $library->id - } - ); - - Koha::AuthorisedValues->search( { authorised_value => 3, category => 'LOST' } )->delete; - my $lost_av = $builder->build_object( - { - class => 'Koha::AuthorisedValues', - value => { - authorised_value => 3, - category => 'LOST', - lib => 'internal description', - lib_opac => 'public description', - } - } - ); - - my $class_sort_rule = $builder->build_object( { class => 'Koha::ClassSortRules', value => { sort_routine => 'Generic' } } ); - my $class_split_rule = $builder->build_object( { class => 'Koha::ClassSplitRules' } ); - my $class_source = $builder->build_object( - { - class => 'Koha::ClassSources', - value => { - class_sort_rule => $class_sort_rule->class_sort_rule, - class_split_rule => $class_split_rule->class_split_rule, - } - } - )->store(); - - $item->set( - { - cn_source => $class_source->id, - itemlost => $lost_av->authorised_value, - itype => $itype->itemtype, - materials => 'Suff', - } - )->store->discard_changes; - - my $strings = $item->strings_map; - - subtest 'unmapped field tests' => sub { - - plan tests => 1; - - ok( !exists $strings->{materials}, "Unmapped field not present" ); - }; - - subtest 'av handling' => sub { - - plan tests => 4; - - ok( exists $strings->{itemlost}, "'itemlost' entry exists" ); - is( $strings->{itemlost}->{str}, $lost_av->lib, "'str' set to av->lib" ); - is( $strings->{itemlost}->{type}, 'av', "'type' is 'av'" ); - is( $strings->{itemlost}->{category}, 'LOST', "'category' exists and set to 'LOST'" ); - }; - - subtest 'cn_source handling' => sub { - - plan tests => 3; - - ok( exists $strings->{cn_source}, "'cn_source' entry exists" ); - is( $strings->{cn_source}->{str}, $class_source->description, "'str' set to \$class_source->description" ); - is( $strings->{cn_source}->{type}, 'call_number_source', "type is 'library'" ); - }; - - subtest 'branches handling' => sub { - - plan tests => 3; - - ok( exists $strings->{homebranch}, "'homebranch' entry exists" ); - is( $strings->{homebranch}->{str}, $library->branchname, "'str' set to 'branchname'" ); - is( $strings->{homebranch}->{type}, 'library', "type is 'library'" ); - }; - - subtest 'itemtype handling' => sub { - - plan tests => 3; - - ok( exists $strings->{itype}, "'itype' entry exists" ); - is( $strings->{itype}->{str}, $itype->description, "'str' correctly set" ); - is( $strings->{itype}->{type}, 'item_type', "'type' is 'item_type'" ); - }; - - subtest 'public flag tests' => sub { - - plan tests => 4; - - $strings = $item->strings_map( { public => 1 } ); - - ok( exists $strings->{itemlost}, "'itemlost' entry exists" ); - is( $strings->{itemlost}->{str}, $lost_av->lib_opac, "'str' set to av->lib" ); - is( $strings->{itemlost}->{type}, 'av', "'type' is 'av'" ); - is( $strings->{itemlost}->{category}, 'LOST', "'category' exists and set to 'LOST'" ); - }; - - $cache->clear_from_cache("MarcStructure-0-"); - $cache->clear_from_cache("MarcStructure-1-"); - $cache->clear_from_cache("MarcSubfieldStructure-"); - $cache->clear_from_cache("libraries:name"); - $cache->clear_from_cache("itemtype:description:en"); - $cache->clear_from_cache("cn_sources:description"); - - $schema->storage->txn_rollback; -}; - subtest 'store() tests' => sub { plan tests => 3; -- 2.39.5