Bugzilla – Attachment 159572 Details for
Bug 35471
Automatically select child MARC framework when adding child records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35471: Add Koha::Template::Plugin::Frameworks->GetChildren()
Bug-35471-Add-KohaTemplatePluginFrameworks-GetChil.patch (text/plain), 4.39 KB, created by
Lari Taskula
on 2023-12-05 00:58:57 UTC
(
hide
)
Description:
Bug 35471: Add Koha::Template::Plugin::Frameworks->GetChildren()
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2023-12-05 00:58:57 UTC
Size:
4.39 KB
patch
obsolete
>From dc7cd90149846fe3454d3d869724cd20f7ab7dd6 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Fri, 1 Dec 2023 22:23:49 +0000 >Subject: [PATCH] Bug 35471: Add > Koha::Template::Plugin::Frameworks->GetChildren() > >To test: >1. prove t/db_dependent/Koha/Template/Plugin/Frameworks.t > >Sponsored-by: Hypernova Oy >--- > Koha/Template/Plugin/Frameworks.pm | 21 +++++ > .../Koha/Template/Plugin/Frameworks.t | 81 +++++++++++++++++++ > 2 files changed, 102 insertions(+) > create mode 100755 t/db_dependent/Koha/Template/Plugin/Frameworks.t > >diff --git a/Koha/Template/Plugin/Frameworks.pm b/Koha/Template/Plugin/Frameworks.pm >index 01305455be..49c8c92b55 100644 >--- a/Koha/Template/Plugin/Frameworks.pm >+++ b/Koha/Template/Plugin/Frameworks.pm >@@ -56,4 +56,25 @@ sub GetName { > return $frameworktext; > } > >+=head3 GetChildren >+ >+[% Frameworks.GetChildren( frameworkcode ) %] >+ >+Return the child frameworks ordered by frameworktext >+ >+=cut >+ >+sub GetChildren { >+ my ( $self, $frameworkcode ) = @_; >+ return [] unless defined $frameworkcode; >+ return [] if $frameworkcode eq q{}; >+ >+ my $child_frameworks = Koha::BiblioFrameworks->search( >+ { parent_frameworkcode => $frameworkcode }, >+ { order_by => ['frameworktext'], } >+ )->unblessed; >+ >+ return $child_frameworks; >+} >+ > 1; >diff --git a/t/db_dependent/Koha/Template/Plugin/Frameworks.t b/t/db_dependent/Koha/Template/Plugin/Frameworks.t >new file mode 100755 >index 0000000000..e5d1e62842 >--- /dev/null >+++ b/t/db_dependent/Koha/Template/Plugin/Frameworks.t >@@ -0,0 +1,81 @@ >+#!/usr/bin/env perl >+ >+# Copyright 2023 Hypernova Oy >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+ >+use t::lib::TestBuilder; >+ >+use Koha::Database; >+use Koha::Template::Plugin::Frameworks; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::Frameworks'); >+} >+ >+my $builder = t::lib::TestBuilder->new; >+ >+my $schema = Koha::Database->new->schema; >+ >+subtest 'GetChildren() tests' => sub { >+ >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $parent_framework = $builder->build_object( { class => 'Koha::BiblioFrameworks' } ); >+ >+ my $plugin = Koha::Template::Plugin::Frameworks->new(); >+ >+ is( scalar @{ $plugin->GetChildren() }, 0, 'No child frameworks' ); >+ is( scalar @{ $plugin->GetChildren( $parent_framework->frameworkcode ) }, 0, 'No child frameworks' ); >+ >+ my $child_framework = $builder->build_object( >+ { >+ class => 'Koha::BiblioFrameworks', >+ value => { parent_frameworkcode => $parent_framework->frameworkcode, frameworktext => 'afirst' } >+ } >+ ); >+ is( scalar @{ $plugin->GetChildren( $parent_framework->frameworkcode ) }, 1, 'One child framework' ); >+ is( >+ $plugin->GetChildren( $parent_framework->frameworkcode )->[0]->{'frameworkcode'}, >+ $child_framework->frameworkcode, 'No child frameworks' >+ ); >+ my $child_framework2 = $builder->build_object( >+ { >+ class => 'Koha::BiblioFrameworks', >+ value => { parent_frameworkcode => $parent_framework->frameworkcode, frameworktext => 'bsecond' } >+ } >+ ); >+ is( scalar @{ $plugin->GetChildren( $parent_framework->frameworkcode ) }, 2, 'Two child frameworks' ); >+ >+ # note: elements returned by GetChildren() are ordered by frameworktext >+ # the two following tests depend on this fact >+ is( >+ $plugin->GetChildren( $parent_framework->frameworkcode )->[0]->{'frameworkcode'}, >+ $child_framework->frameworkcode, 'First child framework found' >+ ); >+ is( >+ $plugin->GetChildren( $parent_framework->frameworkcode )->[1]->{'frameworkcode'}, >+ $child_framework2->frameworkcode, 'Second child framework found' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.34.1
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 35471
:
159486
|
159487
|
159488
|
159489
|
159490
|
159491
|
159492
|
159493
|
159494
|
159495
|
159496
|
159497
|
159498
|
159499
|
159500
|
159567
|
159568
|
159569
|
159570
|
159571
| 159572 |
159573
|
159884