Bugzilla – Attachment 141392 Details for
Bug 31333
Add the ability to limit purchase suggestions by patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31333: (QA follow-up) Move and improve tests
Bug-31333-QA-follow-up-Move-and-improve-tests.patch (text/plain), 5.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-10-05 18:10:55 UTC
(
hide
)
Description:
Bug 31333: (QA follow-up) Move and improve tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-10-05 18:10:55 UTC
Size:
5.63 KB
patch
obsolete
>From 57f23c6bd12df644fe814e6cf2df3f20f9f34969 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 5 Oct 2022 11:53:46 -0300 >Subject: [PATCH] Bug 31333: (QA follow-up) Move and improve tests > >This patch moves tests to the right file (singular class name). It also >refactors them a bit, in order to cover more cases, including the >syspref split one. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron/Category.t \ > t/db_dependent/Koha/Patron/Categories.t >=> SUCCESS: All good. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Patron/Categories.t | 27 +------------ > t/db_dependent/Koha/Patron/Category.t | 52 ++++++++++++++++++++++++- > 2 files changed, 52 insertions(+), 27 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron/Categories.t b/t/db_dependent/Koha/Patron/Categories.t >index 6be30bb82a..f6cdba7e24 100755 >--- a/t/db_dependent/Koha/Patron/Categories.t >+++ b/t/db_dependent/Koha/Patron/Categories.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 10; > > use C4::Context; > use Koha::Database; >@@ -115,30 +115,5 @@ my $new_category_4 = Koha::Patron::Category->new( > )->store; > is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'upperagelimit and dateofbirthrequired should have a default value if empty string is passed' ); > >-subtest 'can_make_suggestions' => sub { >- plan tests => 5; >- t::lib::Mocks::mock_preference('suggestion', 0); >- my $category = Koha::Patron::Category->new({ >- categorycode => 'the_cat', >- category_type => 'A', >- description => 'thecatdesc', >- enrolementperiod => undef >- })->store; >- is ( $category->can_make_suggestions, undef, 'With suggestion syspref disabled and suggestionPatronCategoryExceptions syspref empty then Koha::Patron::Category->can_make_suggestions() returns undef' ); >- >- t::lib::Mocks::mock_preference('suggestion', 1); >- is( $category->can_make_suggestions, 1, 'With suggestion syspref enabled and suggestionPatronsCategoryExceptions syspref empty then Koha::Patron::Category->can_make_suggestions() returns 1' ); >- >- t::lib::Mocks::mock_preference('suggestionPatronCategoryExceptions', 'the_cat'); >- is( $category->can_make_suggestions, undef, 'With suggestion syspref enabled and suggestionPatronCategoryExceptions syspref = "the_cat" then Koha::Patron::Category->can_make_suggestions() returns undef' ); >- >- t::lib::Mocks::mock_preference('suggestionPatronCategoryExceptions', 'mycatcodeW'); >- is( $category->can_make_suggestions, 1, 'With suggestion syspref enabled and suggestionPatronCategoryExceptions syspref = "mycatcodeW" then Koha::Patron::Category->can_make_suggestions returns 1' ); >- >- t::lib::Mocks::mock_preference('suggestion', 0); >- is( $category->can_make_suggestions, undef, 'With suggestion syspref disabled and suggestionPatronCategoryExceptions syspref = "mycatcodeW" then Koha::Patron::Category->can_make_suggestions returns undef' ); >- $category->delete; >-}; >- > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/Koha/Patron/Category.t b/t/db_dependent/Koha/Patron/Category.t >index be7f32b8de..983c4b2b31 100755 >--- a/t/db_dependent/Koha/Patron/Category.t >+++ b/t/db_dependent/Koha/Patron/Category.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 7; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -219,3 +219,53 @@ subtest 'get_password_expiry_date() tests' => sub { > is( $category->get_password_expiry_date(), dt_from_string()->add( days => 32 )->ymd, "Date correctly calculated from password_expiry_days when set"); > > }; >+ >+subtest 'can_make_suggestions' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'suggestion', 0 ); >+ t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', undef ); >+ >+ my $category_1 = $builder->build_object({ class => 'Koha::Patron::Categories' }); >+ my $category_2 = $builder->build_object({ class => 'Koha::Patron::Categories' }); >+ >+ ok( >+ !$category_1->can_make_suggestions && !$category_2->can_make_suggestions, >+ 'suggestions globally disabled, categories not in exceptions' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'suggestion', 1 ); >+ ok( >+ $category_1->can_make_suggestions && $category_2->can_make_suggestions, >+ 'suggestions globally enabled' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', $category_2->categorycode ); >+ ok( >+ $category_1->can_make_suggestions && !$category_2->can_make_suggestions, >+ 'suggestions enabled, suggestionPatronCategoryExceptions set, so present categories not allowed' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', $category_1->categorycode ); >+ ok( >+ !$category_1->can_make_suggestions && $category_2->can_make_suggestions, >+ 'suggestions enabled, suggestionPatronCategoryExceptions set, so present categories not allowed' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', join( ',', $category_1->categorycode, $category_2->categorycode) ); >+ ok( >+ !$category_1->can_make_suggestions && !$category_2->can_make_suggestions, >+ 'suggestions enabled, suggestionPatronCategoryExceptions set to both categories, both denied' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'suggestion', 0 ); >+ ok( >+ !$category_1->can_make_suggestions && !$category_2->can_make_suggestions, >+ 'suggestions disabled, no matter what the value of suggestionPatronCategoryExceptions is' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.37.3
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 31333
:
139112
|
139113
|
139114
|
139165
|
139897
|
139898
|
139935
|
139936
|
140169
|
140170
|
140171
|
140172
|
140173
|
140174
|
140270
|
140271
|
140272
|
140273
|
140274
|
140275
|
140276
| 141392 |
141393