Bugzilla – Attachment 188253 Details for
Bug 27734
OpacHiddenItems produces a 404 from borrower holds list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27734: Add tests
Bug-27734-Add-tests.patch (text/plain), 4.41 KB, created by
Lari Taskula
on 2025-10-21 17:59:32 UTC
(
hide
)
Description:
Bug 27734: Add tests
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2025-10-21 17:59:32 UTC
Size:
4.41 KB
patch
obsolete
>From 138aa4f8d5ade706414e937eb1a9758059a69452 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Tue, 21 Oct 2025 15:03:16 +0300 >Subject: [PATCH] Bug 27734: Add tests > >--- > t/db_dependent/Output.t | 131 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 129 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Output.t b/t/db_dependent/Output.t >index 5ed9b6e6a54..b344497e370 100755 >--- a/t/db_dependent/Output.t >+++ b/t/db_dependent/Output.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::MockModule; > use Test::NoWarnings; > use Test::Warn; >@@ -30,13 +30,140 @@ use t::lib::TestBuilder; > BEGIN { > use_ok( > 'C4::Output', >- qw( redirect_if_opac_suppressed ) >+ qw( redirect_if_opac_hidden redirect_if_opac_suppressed ) > ); > } > > my $builder = t::lib::TestBuilder->new(); > my $schema = Koha::Database->new()->schema(); > >+subtest 'redirect_if_opac_hidden() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ local *STDOUT; >+ my $stdout; >+ >+ # variable controlling opac hidden status >+ my $opac_hidden; >+ >+ my $auth_mock = Test::MockModule->new('C4::Auth'); >+ $auth_mock->mock( 'safe_exit', sub { warn "safe_exit_called" } ); >+ >+ my $biblio_mock = Test::MockModule->new('Koha::Biblio'); >+ $biblio_mock->mock( 'hidden_in_opac', sub { return $opac_hidden; } ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ >+ my $query = CGI->new(); >+ >+ subtest 'not hidden tests' => sub { >+ >+ plan tests => 1; >+ >+ open STDOUT, '>', \$stdout; >+ $opac_hidden = 0; >+ >+ redirect_if_opac_hidden( $query, $biblio ); >+ >+ is( $stdout, undef, 'No redirection if the biblio is not hidden' ); >+ >+ close STDOUT; >+ }; >+ >+ subtest 'hidden tests' => sub { >+ >+ plan tests => 9; >+ >+ $opac_hidden = 1; >+ >+ { >+ open STDOUT, '>', \$stdout; >+ t::lib::Mocks::mock_preference( 'OpacHiddenRecordRedirect', 1 ); >+ >+ warning_is { >+ redirect_if_opac_hidden( $query, $biblio ); >+ } >+ q{safe_exit_called}, >+ 'Safe exit called on redirection'; >+ >+ like( $stdout, qr{Status: 302 Found} ); >+ like( $stdout, qr{Location: /cgi-bin/koha/opac-blocked.pl\?hidden=1} ); >+ >+ undef $stdout; >+ >+ close STDOUT; >+ } >+ >+ { >+ open STDOUT, '>', \$stdout; >+ t::lib::Mocks::mock_preference( 'OpacHiddenRecordRedirect', 0 ); >+ >+ warning_is { >+ redirect_if_opac_hidden( $query, $biblio ); >+ } >+ q{safe_exit_called}, >+ 'Safe exit called on redirection'; >+ >+ like( $stdout, qr{Status: 302 Found} ); >+ like( $stdout, qr{Location: /cgi-bin/koha/errors/404.pl} ); >+ >+ undef $stdout; >+ >+ close STDOUT; >+ } >+ >+ { >+ open STDOUT, '>', \$stdout; >+ t::lib::Mocks::mock_preference( 'OpacHiddenRecordRedirect', 1 ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ } >+ ); >+ >+ my $patron2 = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', $patron->categorycode ); >+ >+ redirect_if_opac_hidden( $query, $biblio, $patron ); >+ >+ is( $stdout, undef, 'No redirection if the patron category is excluded from hidden items' ); >+ >+ undef $stdout; >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', $patron2->categorycode ); >+ >+ warning_is { >+ redirect_if_opac_hidden( $query, $biblio, $patron ); >+ } >+ q{safe_exit_called}, >+ 'Safe exit called on redirection'; >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', '' ); >+ >+ warning_is { >+ redirect_if_opac_hidden( $query, $biblio, $patron ); >+ } >+ q{safe_exit_called}, >+ 'Safe exit called on redirection'; >+ >+ undef $stdout; >+ >+ close STDOUT; >+ } >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'redirect_if_opac_suppressed() tests' => sub { > > plan tests => 2; >-- >2.34.1
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 27734
:
121749
|
121797
|
121988
|
121989
|
121990
|
173166
|
173167
|
173168
|
175807
|
175808
| 188253 |
188254
|
188255
|
188256