Bug 13918 [QA Followup] - Improve $biblio->subtitles()

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Kyle Hall 2015-08-24 11:10:58 -04:00
parent 6257b74834
commit 9844c5a6b9
3 changed files with 71 additions and 7 deletions

View file

@ -37,14 +37,20 @@ Koha::Biblio - Koha Biblio Object class
=cut
=head3 subtitle
=head3 subtitles
my @subtitles = $biblio->subtitles();
Returns list of subtitles for a record.
Keyword to MARC mapping for subtitle must be set for this method to return any possible values.
=cut
sub subtitle {
sub subtitles {
my ( $self ) = @_;
return GetRecordValue( 'subtitle', GetMarcBiblio( $self->id() ), GetFrameworkCode( $self->id() ) );
return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
}

View file

@ -537,8 +537,8 @@
<td class="title">
<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% RESERVE.biblionumber %]">
[% RESERVE.biblio.title %]
[% FOREACH subtitl IN RESERVE.biblio.subtitle %]
[% subtitl.subfield %]
[% FOREACH s IN RESERVE.biblio.subtitles %]
[% s %]
[% END %]
[% RESERVE.item.enumchron %]
</a>
@ -622,9 +622,9 @@
<div class="modal-header">
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
[% IF RESERVE.suspend %]
<h3 id="suspendModal[% RESERVE.reserve_id %]Label">Resume your hold on <i>[% RESERVE.reserves_title %]</i></h3>
<h3 id="suspendModal[% RESERVE.reserve_id %]Label">Resume your hold on <i>[% RESERVE.biblio.title %]</i></h3>
[% ELSE %]
<h3 id="suspendModal[% RESERVE.reserve_id %]Label">Suspend your hold on <i>[% RESERVE.reserves_title %]</i></h3>
<h3 id="suspendModal[% RESERVE.reserve_id %]Label">Suspend your hold on <i>[% RESERVE.biblio.title %]</i></h3>
[% END %]
</div>
<div class="modal-body">

58
t/db_dependent/BiblioObject.t Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/perl
# 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 C4::Context;
use C4::Biblio qw( AddBiblio );
use Koha::Database;
use Koha::Branches;
use Koha::Borrowers;
use Test::More tests => 4;
use_ok('Koha::Biblio');
use_ok('Koha::Biblios');
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my @branches = Koha::Branches->search();
my $borrower = Koha::Borrowers->search()->next();
my $biblio = MARC::Record->new();
$biblio->append_fields(
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kyle' ),
MARC::Field->new( '245', ' ', ' ', a => "Test Record", b => "Test Record Subtitle", b => "Another Test Record Subtitle" ),
);
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
my $field_mappings = Koha::Database->new()->schema()->resultset('Fieldmapping');
$field_mappings->delete();
$field_mappings->create( { field => 'subtitle', fieldcode => '245', subfieldcode => 'b' } );
$biblio = Koha::Biblios->find( $biblionumber );
my @subtitles = $biblio->subtitles();
is( $subtitles[0], 'Test Record Subtitle', 'Got first subtitle correctly' );
is( $subtitles[1], 'Another Test Record Subtitle', 'Got second subtitle correctly' );
$schema->storage->txn_rollback();
1;