From 37ad64142fa0f1a9b01cd6961f2e65c260e13803 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 5 Aug 2021 12:24:31 +0000 Subject: [PATCH] Bug 26302: Changes for substatus, resultbranch in XSLT.t Test plan: Run t/db_dependent/XSLT.t Signed-off-by: Marcel de Rooy Signed-off-by: Owen Leonard --- t/db_dependent/XSLT.t | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 521578947b..d7f41c81a8 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -23,6 +23,8 @@ use Test::Warn; use t::lib::TestBuilder; use t::lib::Mocks; +use Koha::Database; +use Koha::Libraries; use Koha::ItemTypes; BEGIN { @@ -46,13 +48,17 @@ subtest 'transformMARCXML4XSLT tests' => sub { }; subtest 'buildKohaItemsNamespace status tests' => sub { - plan tests => 14; + plan tests => 16; t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2'); + t::lib::Mocks::mock_preference( 'OPACResultsLibrary', 'holdingbranch' ); + t::lib::Mocks::mock_preference( 'resultsMaxItems', '2' ); my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); - my $item = $builder->build_sample_item({ itype => $itype->itemtype }); + my $holdinglibrary = $builder->build_object({ class => 'Koha::Libraries' }); + my $item = $builder->build_sample_item({ itype => $itype->itemtype }); + $item->holdingbranch( $holdinglibrary->branchcode )->store; $item->biblioitem->itemtype($itemtype->itemtype)->store; my $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); @@ -93,19 +99,20 @@ subtest 'buildKohaItemsNamespace status tests' => sub { $item->onloan('2001-01-01')->store; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Checked out},"Checked out status takes precedence over Not for loan"); + like( $xml, qr/other<\/status>/, "Checked out is part of other statuses" ); + like($xml,qr{Checked out},"Checked out status takes precedence over Not for loan"); $item->withdrawn(1)->store; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Withdrawn},"Withdrawn status takes precedence over Checked out"); + like($xml,qr{Withdrawn},"Withdrawn status takes precedence over Checked out"); $item->itemlost(1)->store; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Lost},"Lost status takes precedence over Withdrawn"); + like($xml,qr{Lost},"Lost status takes precedence over Withdrawn"); $item->damaged(1)->store; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Damaged},"Damaged status takes precedence over Lost"); + like($xml,qr{Damaged},"Damaged status takes precedence over Lost"); $builder->build({ source => "Branchtransfer", value => { itemnumber => $item->itemnumber, @@ -114,7 +121,7 @@ subtest 'buildKohaItemsNamespace status tests' => sub { } }); $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{In transit},"In-transit status takes precedence over Damaged"); + like($xml,qr{In transit},"In-transit status takes precedence over Damaged"); my $hold = $builder->build_object({ class => 'Koha::Holds', value => { biblionumber => $item->biblionumber, @@ -124,16 +131,16 @@ subtest 'buildKohaItemsNamespace status tests' => sub { } }); $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Waiting},"Waiting status takes precedence over In transit"); + like($xml,qr{Waiting},"Waiting status takes precedence over In transit"); $builder->build({ source => "TmpHoldsqueue", value => { itemnumber => $item->itemnumber } }); $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Pending hold},"Pending status takes precedence over all"); - - + like($xml,qr{Pending hold},"Pending status takes precedence over all"); + my $library_name = $holdinglibrary->branchname; + like($xml,qr{${library_name}}, "Found resultbranch / holding branch" ); }; $schema->storage->txn_rollback; -- 2.20.1