Bugzilla – Attachment 67388 Details for
Bug 19300
Move C4::Reserves::OPACItemHoldsAllowed to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19300: Replace C4::Reserves::OPACItemHoldsAllowed - tests
Bug-19300-Replace-C4ReservesOPACItemHoldsAllowed--.patch (text/plain), 4.87 KB, created by
Alex Buckley
on 2017-09-27 04:05:51 UTC
(
hide
)
Description:
Bug 19300: Replace C4::Reserves::OPACItemHoldsAllowed - tests
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-09-27 04:05:51 UTC
Size:
4.87 KB
patch
obsolete
>From c1aee2546868e187efb91cac2f1ee530a88bd5e3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 11 Sep 2017 13:59:11 -0300 >Subject: [PATCH] Bug 19300: Replace C4::Reserves::OPACItemHoldsAllowed - tests > >This patch proves that we will not introduce trivial regression. >With the same tests, we will execute the existing code and the new code. > >Test plan: >With only this patch applied, prove t/db_dependent/Koha/IssuingRules.t >should return green > >Followed test plan, patches worked as described >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> >--- > Koha/IssuingRules.pm | 12 +++++++++ > t/db_dependent/Koha/IssuingRules.t | 51 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 62 insertions(+), 1 deletion(-) > >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index e3664df..20bbb45 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -71,6 +71,18 @@ sub get_effective_issuing_rule { > return $rule; > } > >+sub get_opacitemholds_policy { >+ my ( $class, $params ) = @_; >+ >+ my $item = $params->{item}; >+ my $patron = $params->{patron}; >+ >+ return unless $item or $patron; >+ >+ require C4::Reserves; >+ return C4::Reserves::OPACItemHoldsAllowed( $item->unblessed, $patron->unblessed ); >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index 392cdec..0907a94 100644 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -19,13 +19,14 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use Benchmark; > > use Koha::IssuingRules; > > use t::lib::TestBuilder; >+use t::lib::Mocks; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -241,6 +242,54 @@ subtest 'get_effective_issuing_rule' => sub { > }; > }; > >+subtest 'get_opacitemholds_policy' => sub { >+ plan tests => 4; >+ my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); >+ my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { itemtype => $itemtype->itemtype, biblionumber => $biblio->biblionumber } } ); >+ my $item = $builder->build_object( >+ { class => 'Koha::Items', >+ value => { >+ homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblio->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ itype => $itype->itemtype, >+ } >+ } >+ ); >+ >+ Koha::IssuingRules->delete; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => '*', branchcode => '*', opacitemholds => "N"})->store; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => $itype->itemtype, branchcode => '*', opacitemholds => "Y"})->store; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "N"})->store; >+ t::lib::Mocks::mock_preference('item-level_itypes', 1); >+ my $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); >+ is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itype'); >+ t::lib::Mocks::mock_preference('item-level_itypes', 0); >+ $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); >+ is ( $opacitemholds, '', 'Patrons cannot place a hold on this itemtype'); >+ >+ Koha::IssuingRules->delete; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => '*', branchcode => '*', opacitemholds => "N"})->store; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => $itype->itemtype, branchcode => '*', opacitemholds => "N"})->store; >+ Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "Y"})->store; >+ t::lib::Mocks::mock_preference('item-level_itypes', 1); >+ $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); >+ is ( $opacitemholds, '', 'Patrons cannot place a hold on this itype'); >+ t::lib::Mocks::mock_preference('item-level_itypes', 0); >+ $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); >+ is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itemtype'); >+ >+ $patron->delete; >+}; >+ > sub _row_match { > my ($rule, $branchcode, $categorycode, $itemtype) = @_; > >-- >2.1.4
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 19300
:
67119
|
67120
|
67121
|
67388
|
67389
|
67390
|
70101
|
70102
|
70103