Bugzilla – Attachment 122050 Details for
Bug 28299
OpacHiddenItems not working in OPAC lists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28299: Unit tests for buildKohaItemsNamespace
Bug-28299-Unit-tests-for-buildKohaItemsNamespace.patch (text/plain), 4.82 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-06-16 20:00:19 UTC
(
hide
)
Description:
Bug 28299: Unit tests for buildKohaItemsNamespace
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-06-16 20:00:19 UTC
Size:
4.82 KB
patch
obsolete
>From dcf52b25a10de59464efc2845c80fe0af66cbbeb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 10 May 2021 11:17:57 -0300 >Subject: [PATCH] Bug 28299: Unit tests for buildKohaItemsNamespace > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/XSLT.t | 71 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 70 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index 37637e6fa8..f90baff197 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use MARC::Record; >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::Warn; > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -137,3 +137,72 @@ subtest 'buildKohaItemsNamespace status tests' => sub { > }; > > $schema->storage->txn_rollback; >+ >+subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { >+ >+ plan tests => 20; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ # Have two known libraries for testing purposes >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_3 = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_1->id }); >+ my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_2->id }); >+ my $item_3 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_3->id }); >+ >+ my $items_rs = $biblio->items->search({ "me.itemnumber" => { '!=' => $item_3->itemnumber } }); >+ >+ ## Test passing items_rs only >+ my $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $items_rs ); >+ >+ my $library_1_name = $library_1->branchname; >+ my $library_2_name = $library_2->branchname; >+ my $library_3_name = $library_3->branchname; >+ >+ like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); >+ like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ ## Test passing one item in hidden_items and items_rs >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset ); >+ >+ unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); >+ like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ >+ ## Test passing both items in hidden_items and items_rs >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber ], $items_rs->reset ); >+ >+ unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 not present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' ); >+ >+ ## Test passing both items in hidden_items and no items_rs >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber, $item_3->itemnumber ] ); >+ >+ unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 not present in the XML' ); >+ unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); >+ is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' ); >+ >+ ## Test passing one item in hidden_items and items_rs >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ] ); >+ >+ unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); >+ like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); >+ like( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 present in the XML' ); >+ >+ ## Test not passing any param >+ $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber ); >+ >+ like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); >+ like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); >+ like( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 present in the XML' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28299
:
120662
|
120756
|
120769
|
120792
|
120795
|
121018
|
121021
|
121022
|
121023
|
122050
|
122051
|
122052
|
122196
|
122197
|
122198
|
122593
|
122594
|
122595