Bugzilla – Attachment 62415 Details for
Bug 18433
Allow to select results to export in item search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18433: Use existing pattern for find_by_koha_field
Bug-18433-Use-existing-pattern-for-findbykohafield.patch (text/plain), 3.70 KB, created by
Jonathan Druart
on 2017-04-19 19:17:36 UTC
(
hide
)
Description:
Bug 18433: Use existing pattern for find_by_koha_field
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-04-19 19:17:36 UTC
Size:
3.70 KB
patch
obsolete
>From 4b8e6139d16fba7f18fc6c981d2e7baafac7731d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 19 Apr 2017 16:14:37 -0300 >Subject: [PATCH] Bug 18433: Use existing pattern for find_by_koha_field > >--- > Koha/AuthorisedValueCategories.pm | 17 ++++++---- > t/db_dependent/Koha/AuthorisedValueCategories.t | 44 ++++++++++++++----------- > 2 files changed, 35 insertions(+), 26 deletions(-) > >diff --git a/Koha/AuthorisedValueCategories.pm b/Koha/AuthorisedValueCategories.pm >index 767cb92..3a1dae0 100644 >--- a/Koha/AuthorisedValueCategories.pm >+++ b/Koha/AuthorisedValueCategories.pm >@@ -49,13 +49,16 @@ sub find_by_koha_field { > > $frameworkcode //= ''; > >- my ($subfield) = Koha::MarcSubfieldStructures->search({ >- frameworkcode => $frameworkcode, >- kohafield => $kohafield, >- authorised_value => { not => undef }, >- }); >- >- return $subfield ? $class->find($subfield->authorised_value) : undef; >+ my $avc = $class->SUPER::search( >+ { 'marc_subfield_structures.frameworkcode' => $frameworkcode, >+ 'marc_subfield_structures.kohafield' => $kohafield, >+ 'marc_subfield_structures.authorised_value' => { not => undef }, >+ }, >+ { join => 'marc_subfield_structures', >+ distinct => 1, >+ } >+ ); >+ return $avc->count ? $avc->next : undef; > } > > =head3 type >diff --git a/t/db_dependent/Koha/AuthorisedValueCategories.t b/t/db_dependent/Koha/AuthorisedValueCategories.t >index 99735ac..ce00b3d 100755 >--- a/t/db_dependent/Koha/AuthorisedValueCategories.t >+++ b/t/db_dependent/Koha/AuthorisedValueCategories.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 2; > > use Koha::MarcSubfieldStructures; > use Koha::Database; >@@ -33,27 +33,33 @@ BEGIN { > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >-my $category = Koha::AuthorisedValueCategories->find_or_create({ >- category_name => 'TEST', >-}); >+subtest '->find_by_koha_field' => sub { >+ plan tests => 3; >+ my $category = Koha::AuthorisedValueCategories->find_or_create({ >+ category_name => 'TEST', >+ }); > >-Koha::MarcSubfieldStructures->search({ >- frameworkcode => '', >- kohafield => 'items.notforloan', >-})->delete(); >+ Koha::MarcSubfieldStructures->search({ >+ frameworkcode => '', >+ kohafield => 'items.notforloan', >+ })->delete(); > >-my $subfield = Koha::MarcSubfieldStructures->find_or_create({ >- frameworkcode => '', >- tagfield => 999, >- tagsubfield => 9, >-}); >-$subfield->authorised_value($category->category_name) >- ->kohafield('items.notforloan') >- ->store(); >+ my $avc = Koha::AuthorisedValueCategories->find_by_koha_field('items.notforloan'); >+ is($avc, undef, '->find_by_koha_field should return undef if no category is linked to this field'); > >-my $result = Koha::AuthorisedValueCategories->find_by_koha_field('items.notforloan'); >+ my $subfield = Koha::MarcSubfieldStructures->find_or_create({ >+ frameworkcode => '', >+ tagfield => 999, >+ tagsubfield => 9, >+ }); >+ $subfield->authorised_value($category->category_name) >+ ->kohafield('items.notforloan') >+ ->store(); > >-isa_ok($result, 'Koha::AuthorisedValueCategory', 'Result found'); >-is($result->category_name, $category->category_name, 'Result is correct'); >+ $avc = Koha::AuthorisedValueCategories->find_by_koha_field('items.notforloan'); >+ >+ isa_ok($avc, 'Koha::AuthorisedValueCategory', '->find_by_koha_field should return a Koha::AuthorisedValueCategory'); >+ is($avc->category_name, $avc->category_name, '->find_by_koha_field should return the correct category'); >+}; > > $schema->storage->txn_rollback; >-- >2.9.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 18433
:
62170
|
62181
|
62358
|
62388
|
62389
|
62390
|
62415
|
62416
|
62417
|
62449
|
62472
|
95380
|
97479
|
99123
|
99124
|
99159
|
99160
|
99161
|
99162