Bugzilla – Attachment 60427 Details for
Bug 18139
'Too many checked out' can confuse librarians
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18139 - Prep unit tests
Bug-18139---Prep-unit-tests.patch (text/plain), 17.31 KB, created by
Kyle M Hall (khall)
on 2017-02-17 15:23:56 UTC
(
hide
)
Description:
Bug 18139 - Prep unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-02-17 15:23:56 UTC
Size:
17.31 KB
patch
obsolete
>From 9f01248cfe0c819c2c39398ab3952fecf25d20c0 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@kylehall.info> >Date: Fri, 17 Feb 2017 10:07:07 -0500 >Subject: [PATCH] Bug 18139 - Prep unit tests > >--- > t/db_dependent/Circulation/TooMany.t | 247 +++++++++++++---------------------- > 1 file changed, 88 insertions(+), 159 deletions(-) > >diff --git a/t/db_dependent/Circulation/TooMany.t b/t/db_dependent/Circulation/TooMany.t >index 428c08b..9c720db 100644 >--- a/t/db_dependent/Circulation/TooMany.t >+++ b/t/db_dependent/Circulation/TooMany.t >@@ -91,21 +91,18 @@ C4::Context->set_userenv($patron->{borrowernumber}, $patron->{userid}, 'usercnum > # OSCO: On-site checkout > > subtest 'no rules exist' => sub { >- plan tests => 2; >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { reason => 'NO_RULE_DEFINED', max_allowed => 0 }, >- 'CO should not be allowed, in any cases' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { reason => 'NO_RULE_DEFINED', max_allowed => 0 }, >- 'OSCO should not be allowed, in any cases' >- ); >+ plan tests => 4; >+ my $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'NO_RULE_DEFINED', 'CO should not be allowed, in any cases' ); >+ is( $too_many->{max_allowed}, 0, 'CO should not be allowed, in any cases' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'NO_RULE_DEFINED', 'CO should not be allowed, in any cases' ); >+ is( $too_many->{max_allowed}, 0, 'CO should not be allowed, in any cases' ); > }; > > subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { >- plan tests => 4; >+ plan tests => 12; > my $issuingrule = $builder->build({ > source => 'Issuingrule', > value => { >@@ -117,44 +114,27 @@ subtest '1 Issuingrule exist 0 0: no issue allowed' => sub { > }, > }); > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 0, >- max_allowed => 0, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 0, >- max_allowed => 0, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >+ my $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 0, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 0, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 0, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 0, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 0, >- max_allowed => 0, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 0, >- max_allowed => 0, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 0, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 0, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 0, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 0, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); > > teardown(); > }; >@@ -199,7 +179,7 @@ subtest '1 Issuingrule exist 1 1: issue is allowed' => sub { > }; > > subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { >- plan tests => 5; >+ plan tests => 11; > my $issuingrule = $builder->build({ > source => 'Issuingrule', > value => { >@@ -215,15 +195,11 @@ subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { > like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >+ my $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ > is( > C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), > undef, >@@ -231,30 +207,22 @@ subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed. Do a CO' => sub { > ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); > > teardown(); > }; > > subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { >- plan tests => 5; >+ plan tests => 11; > my $issuingrule = $builder->build({ > source => 'Issuingrule', > value => { >@@ -275,35 +243,22 @@ subtest '1 Issuingrule exist: 1 CO allowed, 1 OSCO allowed, Do a OSCO' => sub { > undef, > 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' > ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >+ >+ my $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); > > teardown(); > }; >@@ -312,7 +267,7 @@ subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { > # Note: the same test coul be done for > # DefaultBorrowerCircRule, DefaultBranchCircRule, DefaultBranchItemRule ans DefaultCircRule.pm > >- plan tests => 10; >+ plan tests => 22; > my $issuingrule = $builder->build({ > source => 'BranchBorrowerCircRule', > value => { >@@ -327,15 +282,11 @@ subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { > like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 0); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >+ my $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ > is( > C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), > undef, >@@ -343,24 +294,15 @@ subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { > ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); > > teardown(); > >@@ -373,35 +315,22 @@ subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub { > undef, > 'CO should be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' > ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' >- ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{count}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); >+ is( $too_many->{max_allowed}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 0' ); > > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ), >- { >- reason => 'TOO_MANY_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >- is_deeply( >- C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ), >- { >- reason => 'TOO_MANY_ONSITE_CHECKOUTS', >- count => 1, >- max_allowed => 1, >- }, >- 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' >- ); >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item ); >+ is( $too_many->{reason}, 'TOO_MANY_CHECKOUTS', 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'CO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ >+ $too_many = C4::Circulation::TooMany( $patron, $biblio->{biblionumber}, $item, { onsite_checkout => 1 } ); >+ is( $too_many->{reason}, 'TOO_MANY_ONSITE_CHECKOUTS', 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{count}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); >+ is( $too_many->{max_allowed}, 1, 'OSCO should not be allowed if ConsiderOnSiteCheckoutsAsNormalCheckouts == 1' ); > > teardown(); > }; >-- >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 18139
:
60427
|
60428
|
60429
|
61489
|
61490
|
61491
|
61541
|
61542
|
61543
|
61663
|
159307
|
159308
|
159522
|
159523
|
159728
|
159729
|
159740
|
159904
|
159905
|
159906
|
159907