Bugzilla – Attachment 42291 Details for
Bug 9223
Multiple values of AdvancedSearchTypes in suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9223 [Follow-up] add unit tests for GetSupportList and GetSupportName subroutine
Bug-9223-Follow-up-add-unit-tests-for-GetSupportLi.patch (text/plain), 4.00 KB, created by
Alex Arnaud
on 2015-09-03 10:21:32 UTC
(
hide
)
Description:
Bug 9223 [Follow-up] add unit tests for GetSupportList and GetSupportName subroutine
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2015-09-03 10:21:32 UTC
Size:
4.00 KB
patch
obsolete
>From 0816a0ba53cd96e3abbdee34a8f5b4e3c7409e14 Mon Sep 17 00:00:00 2001 >From: Koha <koha@localhost> >Date: Tue, 9 Jun 2015 09:58:58 +0200 >Subject: [PATCH] Bug 9223 [Follow-up] add unit tests for GetSupportList and > GetSupportName subroutine > >--- > t/db_dependent/Suggestions.t | 69 +++++++++++++++++++++++++++++++++++++----- > 1 file changed, 61 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 29e59bb..8f10682 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -26,7 +26,8 @@ use C4::Budgets qw( AddBudgetPeriod AddBudget ); > use Koha::DateUtils qw( dt_from_string ); > > use DateTime::Duration; >-use Test::More tests => 105; >+use Test::More tests => 110; >+use Test::MockModule; > use Test::Warn; > > BEGIN { >@@ -41,6 +42,48 @@ my $sql; > $dbh->{AutoCommit} = 0; > $dbh->{RaiseError} = 1; > >+my $koha = new Test::MockModule('C4::Koha'); >+$koha->mock( >+ 'GetAuthorisedValues', >+ sub { >+ my $category = shift; >+ >+ my $ret = []; >+ if ($category eq 'ccode') { >+ $ret = [ >+ { >+ 'imageurl' => '', >+ 'authorised_value' => 'TH', >+ 'lib_opac' => "Thesis", >+ 'lib' => "Thesis", >+ 'category' => 'CCODE', >+ 'id' => '3810', >+ 'selected' => 0 >+ }, >+ { >+ 'imageurl' => '', >+ 'authorised_value' => 'BOOK', >+ 'lib_opac' => 'Book', >+ 'lib' => 'Book', >+ 'category' => 'CCODE', >+ 'id' => '3807', >+ 'selected' => 0 >+ }, >+ >+ ]; >+ } >+ >+ return $ret; >+ } >+); >+ >+$koha->mock( >+ 'GetKohaAuthorisedValueLib', >+ sub { >+ return 'Thesis'; >+ } >+); >+ > # Reset item types to only the default ones > $dbh->do(q|DELETE FROM itemtypes;|); > $sql = " >@@ -342,16 +385,26 @@ $suggestions = GetSuggestionByStatus('CHECKED'); > is( @$suggestions, 1, 'DelSuggestion deletes one suggestion' ); > is( $suggestions->[0]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); > >-## Bug 11466, making sure GetSupportList() returns itemtypes, even if AdvancedSearchTypes has multiple values >-C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes|loc|ccode'); >+C4::Context->set_preference('SuggestionsUseValues', 'itemtypes'); > my $itemtypes1 = C4::Koha::GetSupportList(); >-is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, multiple AdvancedSearchTypes"); >+is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes"); >+my $mp_description = C4::Koha::GetSupportName('MP'); >+is($mp_description, 'Maps', 'Purchase suggestion itemtypes collected, itemtype MP description should be Maps'); >+ >+is($itemtypes1->[0]{'authorised_value'},'BK', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes first authorized value is BK"); >+is($itemtypes1->[0]{'lib'},'Books', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes first lib is books"); >+is($itemtypes1->[0]{'imageurl'},'bridge/book.gif', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes, first imageurl is bridge/book.gif"); >+ >+C4::Context->set_preference('SuggestionsUseValues', 'ccode'); >+my $ccodes = C4::Koha::GetSupportList(); >+is(@$ccodes, 2, "Purchase suggestion itemtypes collected, SuggestionsUseValues is ccode"); >+my $th_description = C4::Koha::GetSupportName('TH'); >+is($th_description, 'Thesis', 'Purchase suggestion itemtypes collected, ccode TH description should be Thesis'); > >-C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes'); >-my $itemtypes2 = C4::Koha::GetSupportList(); >-is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSearchTypes"); > >-is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved'); >+C4::Context->set_preference('SuggestionsUseValues', 'none'); >+my $empty = C4::Koha::GetSupportList(); >+is(@$empty, 0, "Purchase suggestion itemtypes collected, SuggestionsUseValues is None"); > > # Test budgetid fk > $my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB >-- >1.7.10.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 9223
:
13903
|
14427
|
14428
|
20015
|
20016
|
20017
|
35492
|
35493
|
35494
|
36178
|
36179
|
36702
|
36703
|
36704
|
40011
|
40012
|
40013
|
40014
|
40015
|
40016
|
42287
|
42288
|
42289
|
42290
|
42291
|
42336
|
42337
|
42338
|
42339
|
42340
|
44111
|
44113
|
44114
|
44115
|
44116
|
44117
|
44118