Bugzilla – Attachment 11441 Details for
Bug 7417
Include alternate forms from authorities in bibliographic searches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7417 follow-up: additional QA fixes
Bug-7417-follow-up-additional-QA-fixes.patch (text/plain), 24.48 KB, created by
Jared Camins-Esakov
on 2012-08-08 12:13:51 UTC
(
hide
)
Description:
Bug 7417 follow-up: additional QA fixes
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-08-08 12:13:51 UTC
Size:
24.48 KB
patch
obsolete
>From aba2c04415d8b4441c123806a1dbe85395c21a05 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Wed, 8 Aug 2012 08:10:36 -0400 >Subject: [PATCH] Bug 7417 follow-up: additional QA fixes >Content-Type: text/plain; charset="UTF-8" > >* perltidied all new files again >* wrote an intelligent constructor for Koha::DataObject::Authority which > takes a hash with the construction criteria >* added rudimentary error handling in C4::AuthoritiesMarc::GetAuthority >* added missing t/AuthoritiesMarc.t >--- > C4/AuthoritiesMarc.pm | 5 +- > Koha/DataObject/Authority.pm | 85 ++++++++++++++++------------- > Koha/Filter/MARC/EmbedSeeFromHeadings.pm | 29 ++++++----- > Koha/Filter/MARC/Null.pm | 5 +- > Koha/RecordProcessor.pm | 40 ++++++++------ > Koha/RecordProcessor/Base.pm | 19 ++++--- > t/AuthoritiesMarc.t | 31 +++++++++-- > t/RecordProcessor.t | 61 +++++++++++++-------- > t/RecordProcessor_EmbedSeeFromHeadings.t | 68 +++++++++++++----------- > t/db_dependent/Koha_Authority.t | 37 +++++++------ > 10 files changed, 222 insertions(+), 158 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index c2c3991..14cfb02 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -849,8 +849,9 @@ Returns MARC::Record of the authority passed in parameter. > > sub GetAuthority { > my ($authid)=@_; >- my $authority = Koha::DataObject::Authority->get_from_authid($authid); >- return ($authority->record); >+ my $authority = Koha::DataObject::Authority->new( { authid => $authid } ); >+ return unless $authority; >+ return ($authority->marcrecord); > } > > =head2 GetAuthType >diff --git a/Koha/DataObject/Authority.pm b/Koha/DataObject/Authority.pm >index 119da67..9a349aa 100644 >--- a/Koha/DataObject/Authority.pm >+++ b/Koha/DataObject/Authority.pm >@@ -38,53 +38,62 @@ use MARC::File::XML; > use C4::Charset; > use Class::Accessor "antlers"; > >-has authid => ( is => 'rw' ); >-has authtype => ( is => 'rw' ); >-has record => ( is => 'rw' ); >+has authid => ( is => 'rw' ); >+has authtype => ( is => 'rw' ); >+has marcrecord => ( is => 'rw' ); > has marcflavour => ( is => 'rw' ); > > =head2 new > >- my $auth = Koha::DataObject::Authority->new($record); >+ my $auth = Koha::DataObject::Authority->new($args); > >-Create a new Koha::DataObject::Authority object based on the provided record. >+Create a new Koha::DataObject::Authority object based on the criteria in >+the provided hashref. If $args->{marcrecord} contains a MARC::Record >+object, create the Authority object based on that. If $args->{authid} >+is set, retrieve the authority with the specified authid. > > =cut >-sub new { >- my $class = shift; >- my $record = shift; >- >- my $self = $class->SUPER::new( { record => $record }); >- >- bless $self, $class; >- return $self; >-} >- >-=head2 get_from_authid >- >- my $auth = Koha::DataObject::Authority->get_from_authid($authid); > >-Create the Koha::DataObject::Authority object associated with the provided authid. >- >-=cut >-sub get_from_authid { >+sub new { > my $class = shift; >- my $authid = shift; >- my $marcflavour = C4::Context->preference("marcflavour"); >- >- my $dbh=C4::Context->dbh; >- my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?"); >- $sth->execute($authid); >- my ($authtypecode, $marcxml) = $sth->fetchrow; >- my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8', >- (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))}; >- return if ($@); >- $record->encoding('UTF-8'); >- >- my $self = $class->SUPER::new( { authid => $authid, >- marcflavour => $marcflavour, >- authtype => $authtypecode, >- record => $record }); >+ my $args = shift; >+ >+ my $self = $class->SUPER::new(); >+ if ( defined $args->{'marcrecord'} >+ && ref $args->{'marcrecord'} eq 'MARC::Record' ) >+ { >+ $self = $class->SUPER::new( { marcrecord => $args->{'marcrecord'} } ); >+ } >+ elsif ( defined $args->{'authid'} ) { >+ my $marcflavour = C4::Context->preference("marcflavour"); >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare( >+ "select authtypecode, marcxml from auth_header where authid=?"); >+ $sth->execute( $args->{'authid'} ); >+ my ( $authtypecode, $marcxml ) = $sth->fetchrow; >+ my $record = eval { >+ MARC::Record->new_from_xml( >+ StripNonXmlChars($marcxml), >+ 'UTF-8', >+ ( >+ C4::Context->preference("marcflavour") eq "UNIMARC" >+ ? "UNIMARCAUTH" >+ : C4::Context->preference("marcflavour") >+ ) >+ ); >+ }; >+ return if ($@); >+ $record->encoding('UTF-8'); >+ >+ $self = $class->SUPER::new( >+ { >+ authid => $args->{'authid'}, >+ marcflavour => $marcflavour, >+ authtype => $authtypecode, >+ marcrecord => $record >+ } >+ ); >+ } > > bless $self, $class; > return $self; >diff --git a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm >index 6457b4c..d912bd2 100644 >--- a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm >+++ b/Koha/Filter/MARC/EmbedSeeFromHeadings.pm >@@ -35,7 +35,7 @@ use Carp; > use Koha::DataObject::Authority; > > use base qw(Koha::RecordProcessor::Base); >-our $NAME = 'EmbedSeeFromHeadings'; >+our $NAME = 'EmbedSeeFromHeadings'; > our $VERSION = '1.0'; > > =head2 filter >@@ -48,20 +48,22 @@ In order to differentiate added headings from actual headings, a 'z' is > put in the first indicator. > > =cut >+ > sub filter { >- my $self = shift; >+ my $self = shift; > my $record = shift; > my $newrecord; > > return unless defined $record; > >- if (ref $record eq 'ARRAY') { >+ if ( ref $record eq 'ARRAY' ) { > my @recarray; > foreach my $thisrec (@$record) { > push @recarray, _processrecord($thisrec); > } > $newrecord = \@recarray; >- } elsif (ref $record eq 'MARC::Record') { >+ } >+ elsif ( ref $record eq 'MARC::Record' ) { > $newrecord = _processrecord($record); > } > >@@ -80,20 +82,21 @@ sub _processrecord { > my $authority = Koha::DataObject::Authority->get_from_authid($authid); > next unless $authority; > my $auth_marc = $authority->record; >- my @seefrom = $auth_marc->field('4..'); >+ my @seefrom = $auth_marc->field('4..'); > my @newfields; > foreach my $authfield (@seefrom) { >- my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2); >- my $newfield = MARC::Field->new($tag, >- 'z', >- $authfield->indicator(2) || ' ', >- '9' => '1'); >- foreach my $sub ($authfield->subfields()) { >- my ($code,$val) = @$sub; >+ my $tag = >+ substr( $field->tag(), 0, 1 ) . substr( $authfield->tag(), 1, 2 ); >+ my $newfield = >+ MARC::Field->new( $tag, 'z', $authfield->indicator(2) || ' ', >+ '9' => '1' ); >+ foreach my $sub ( $authfield->subfields() ) { >+ my ( $code, $val ) = @$sub; > $newfield->add_subfields( $code => $val ); > } > $newfield->delete_subfield( code => '9' ); >- push @newfields, $newfield if (scalar($newfield->subfields()) > 0); >+ push @newfields, $newfield >+ if ( scalar( $newfield->subfields() ) > 0 ); > } > $record->append_fields(@newfields); > } >diff --git a/Koha/Filter/MARC/Null.pm b/Koha/Filter/MARC/Null.pm >index a84384b..46fd30e 100644 >--- a/Koha/Filter/MARC/Null.pm >+++ b/Koha/Filter/MARC/Null.pm >@@ -35,7 +35,7 @@ use Modern::Perl; > use Carp; > > use base qw(Koha::RecordProcessor::Base); >-our $NAME = 'Null'; >+our $NAME = 'Null'; > our $VERSION = '1.0'; > > =head2 filter >@@ -46,8 +46,9 @@ our $VERSION = '1.0'; > Return the original record. > > =cut >+ > sub filter { >- my $self = shift; >+ my $self = shift; > my $record = shift; > > return $record; >diff --git a/Koha/RecordProcessor.pm b/Koha/RecordProcessor.pm >index dcee39c..3a30481 100644 >--- a/Koha/RecordProcessor.pm >+++ b/Koha/RecordProcessor.pm >@@ -62,10 +62,10 @@ use Class::Accessor "antlers"; > use Module::Load::Conditional qw(can_load); > use Module::Pluggable::Object; > >-has schema => ( is => "rw" ); >+has schema => ( is => "rw" ); > has filters => ( is => "rw" ); > has options => ( is => "rw" ); >-has record => ( is => "rw" ); >+has record => ( is => "rw" ); > > =head2 new > >@@ -90,28 +90,33 @@ Koha::Filter::${schema} namespace, as only the filter name, and > =back > > =cut >+ > sub new { > my $class = shift; > my $param = shift; > >- >- my $schema = $param->{schema} || 'MARC'; >+ my $schema = $param->{schema} || 'MARC'; > my $options = $param->{options} || ''; >- my @filters = ( ); >+ my @filters = (); > >- foreach my $filter ($param->{filters}) { >+ foreach my $filter ( $param->{filters} ) { > next unless $filter; >- my $filter_module = $filter =~ m/:/ ? $filter : "Koha::Filter::${schema}::${filter}"; >- if (can_load( modules => { $filter_module => undef } )) { >+ my $filter_module = >+ $filter =~ m/:/ ? $filter : "Koha::Filter::${schema}::${filter}"; >+ if ( can_load( modules => { $filter_module => undef } ) ) { > my $object = $filter_module->new(); > $filter_module->initialize($param); > push @filters, $object; > } > } > >- my $self = $class->SUPER::new( { schema => $schema, >- filters => \@filters, >- options => $options }); >+ my $self = $class->SUPER::new( >+ { >+ schema => $schema, >+ filters => \@filters, >+ options => $options >+ } >+ ); > bless $self, $class; > return $self; > } >@@ -123,8 +128,9 @@ sub new { > Bind a normalizer to a particular record. > > =cut >+ > sub bind { >- my $self = shift; >+ my $self = shift; > my $record = shift; > > $self->{record} = $record; >@@ -141,6 +147,7 @@ Note that $record may be either a scalar or an arrayref, and the > return value will be of the same type. > > =cut >+ > sub process { > my $self = shift; > my $record = shift || $self->record; >@@ -149,7 +156,7 @@ sub process { > > my $newrecord = $record; > >- foreach my $filterobj (@{$self->filters}) { >+ foreach my $filterobj ( @{ $self->filters } ) { > next unless $filterobj; > $newrecord = $filterobj->filter($newrecord); > } >@@ -160,7 +167,7 @@ sub process { > sub DESTROY { > my $self = shift; > >- foreach my $filterobj (@{$self->filters}) { >+ foreach my $filterobj ( @{ $self->filters } ) { > $filterobj->destroy(); > } > } >@@ -173,11 +180,12 @@ Get a list of available filters. Optionally specify the metadata schema. > At present only MARC is supported as a schema. > > =cut >+ > sub AvailableFilters { > my $schema = pop || ''; > my $path = 'Koha::Filter'; >- $path .= "::$schema" if ($schema eq 'MARC'); >- my $finder = Module::Pluggable::Object->new(search_path => $path); >+ $path .= "::$schema" if ( $schema eq 'MARC' ); >+ my $finder = Module::Pluggable::Object->new( search_path => $path ); > return $finder->plugins; > } > >diff --git a/Koha/RecordProcessor/Base.pm b/Koha/RecordProcessor/Base.pm >index 52a541b..efca01b 100644 >--- a/Koha/RecordProcessor/Base.pm >+++ b/Koha/RecordProcessor/Base.pm >@@ -61,14 +61,13 @@ clone it I<prior> to passing it off to the RecordProcessor. > use Modern::Perl; > use Class::Accessor "antlers"; > >-has name => ( is => "ro" ); >+has name => ( is => "ro" ); > has version => ( is => "ro" ); >-has params => ( is => "rw" ); >+has params => ( is => "rw" ); > >-our $NAME = 'Base'; >+our $NAME = 'Base'; > our $VERSION = '1.0'; > >- > =head2 new > > my $filter = Koha::RecordProcessor::Base->new; >@@ -76,16 +75,16 @@ our $VERSION = '1.0'; > Create a new filter; > > =cut >+ > sub new { > my $class = shift; > >- my $self = $class->SUPER::new( { }); >+ my $self = $class->SUPER::new( {} ); > > bless $self, $class; > return $self; > } > >- > =head2 initialize > > $filter->initalize(%params); >@@ -93,8 +92,9 @@ sub new { > Initialize a filter using the specified parameters. > > =cut >+ > sub initialize { >- my $self = shift; >+ my $self = shift; > my $params = shift; > > #$self->params = $params; >@@ -102,7 +102,6 @@ sub initialize { > return $self; > } > >- > =head2 destroy > > $filter->destroy(); >@@ -110,6 +109,7 @@ sub initialize { > Destroy the filter. > > =cut >+ > sub destroy { > my $self = shift; > return; >@@ -123,8 +123,9 @@ sub destroy { > Filter the specified record(s) and return the result. > > =cut >+ > sub filter { >- my $self = shift; >+ my $self = shift; > my $record = shift; > return $record; > } >diff --git a/t/AuthoritiesMarc.t b/t/AuthoritiesMarc.t >index d59b43b..59a9a18 100755 >--- a/t/AuthoritiesMarc.t >+++ b/t/AuthoritiesMarc.t >@@ -1,14 +1,35 @@ > #!/usr/bin/perl > # >-# This Koha test module is a stub! >+# This Koha test module is a stub! > # Add more tests here!!! > >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More tests => 1; >+use C4::Context; >+use Test::More tests => 4; > > BEGIN { >- use_ok('C4::AuthoritiesMarc'); >+ use_ok('C4::AuthoritiesMarc'); > } > >+SKIP: >+{ >+ my $authority; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare("SELECT authid FROM auth_header LIMIT 1;"); >+ $sth->execute(); >+ >+ my $authid; >+ for my $row ( $sth->fetchrow_hashref ) { >+ $authid = $row->{'authid'}; >+ } >+ skip 'No authorities', 4 unless $authid; >+ $authority = GetAuthority($authid); >+ >+ is( ref($authority), 'MARC::Record', 'Retrieved valid MARC::Record' ); >+ >+ is( $authority->field('001')->data(), $authid, 'Retrieved correct record' ); >+ >+ $authority = GetAuthority('alphabetsoup'); >+ is( $authority, undef, 'No invalid record is retrieved' ); >+} >diff --git a/t/RecordProcessor.t b/t/RecordProcessor.t >index 32acc6b..bf3de21 100755 >--- a/t/RecordProcessor.t >+++ b/t/RecordProcessor.t >@@ -25,56 +25,69 @@ use MARC::Record; > use Test::More; > > BEGIN { >- use_ok('Koha::RecordProcessor'); >+ use_ok('Koha::RecordProcessor'); > } > >-my $isbn = '0590353403'; >-my $title = 'Foundation'; >-my $marc_record=MARC::Record->new; >-my $field = MARC::Field->new('020','','','a' => $isbn); >+my $isbn = '0590353403'; >+my $title = 'Foundation'; >+my $marc_record = MARC::Record->new; >+my $field = MARC::Field->new( '020', '', '', 'a' => $isbn ); > $marc_record->append_fields($field); >-$field = MARC::Field->new('245','','','a' => $title); >+$field = MARC::Field->new( '245', '', '', 'a' => $title ); > $marc_record->append_fields($field); > >- > my $filterdir = File::Spec->rel2abs('Koha/Filter') . '/MARC'; > >-opendir(my $dh, $filterdir); >-my @installed_filters = map { ( /\.pm$/ && -f "$filterdir/$_" && s/\.pm$// ) ? "Koha::Filters::MARC::$_" : () } readdir($dh); >+opendir( my $dh, $filterdir ); >+my @installed_filters = map { >+ ( /\.pm$/ && -f "$filterdir/$_" && s/\.pm$// ) >+ ? "Koha::Filters::MARC::$_" >+ : () >+} readdir($dh); > my @available_filters = Koha::RecordProcessor::AvailableFilters(); > > foreach my $filter (@installed_filters) { >- ok(grep($filter, @available_filters), "Found filter $filter"); >+ ok( grep( $filter, @available_filters ), "Found filter $filter" ); > } > >-my $marc_filters = grep (/MARC/, @available_filters); >-is(scalar Koha::RecordProcessor::AvailableFilters('MARC'), $marc_filters, 'Retrieved list of MARC filters'); >+my $marc_filters = grep ( /MARC/, @available_filters ); >+is( scalar Koha::RecordProcessor::AvailableFilters('MARC'), >+ $marc_filters, 'Retrieved list of MARC filters' ); > >-my $processor = Koha::RecordProcessor->new( { filters => ( 'ABCD::EFGH::IJKL' ) } ); >+my $processor = >+ Koha::RecordProcessor->new( { filters => ('ABCD::EFGH::IJKL') } ); > >-is(ref($processor), 'Koha::RecordProcessor', 'Created record processor with invalid filter'); >+is( ref($processor), 'Koha::RecordProcessor', >+ 'Created record processor with invalid filter' ); > >-is($processor->process($marc_record), $marc_record, 'Process record with empty processor'); >+is( $processor->process($marc_record), >+ $marc_record, 'Process record with empty processor' ); > >-$processor = Koha::RecordProcessor->new( { filters => ( 'Null' ) } ); >-is(ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Created record processor with implicitly scoped Null filter'); >+$processor = Koha::RecordProcessor->new( { filters => ('Null') } ); >+is( ref( $processor->filters->[0] ), >+ 'Koha::Filter::MARC::Null', >+ 'Created record processor with implicitly scoped Null filter' ); > >-$processor = Koha::RecordProcessor->new( { filters => ( 'Koha::Filter::MARC::Null' ) } ); >-is(ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Created record processor with explicitly scoped Null filter'); >+$processor = >+ Koha::RecordProcessor->new( { filters => ('Koha::Filter::MARC::Null') } ); >+is( ref( $processor->filters->[0] ), >+ 'Koha::Filter::MARC::Null', >+ 'Created record processor with explicitly scoped Null filter' ); > >-is($processor->process($marc_record), $marc_record, 'Process record'); >+is( $processor->process($marc_record), $marc_record, 'Process record' ); > > $processor->bind($marc_record); > >-is($processor->record, $marc_record, 'Bound record to processor'); >+is( $processor->record, $marc_record, 'Bound record to processor' ); > >-is($processor->process(), $marc_record, 'Filter bound record'); >+is( $processor->process(), $marc_record, 'Filter bound record' ); > > eval { >- $processor = Koha::RecordProcessor->new( { filters => ( 'Koha::Filter::MARC::Null' ) } ); >+ $processor = >+ Koha::RecordProcessor->new( { filters => ('Koha::Filter::MARC::Null') } ); > undef $processor; > }; > >-ok(!$@, 'Destroyed processor successfully'); >+ok( !$@, 'Destroyed processor successfully' ); > > done_testing(); >diff --git a/t/RecordProcessor_EmbedSeeFromHeadings.t b/t/RecordProcessor_EmbedSeeFromHeadings.t >index ee3185a..ee60489 100755 >--- a/t/RecordProcessor_EmbedSeeFromHeadings.t >+++ b/t/RecordProcessor_EmbedSeeFromHeadings.t >@@ -34,16 +34,21 @@ BEGIN { > > # Mock the call to create a database handler > my $module = new Test::MockModule('C4::Context'); >-$module->mock('_new_dbh', sub { >- my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >- || die "Cannot create handle: $DBI::errstr\n"; >- return $dbh >-}); >-$module->mock('preference', sub { >- return 'MARC21' if (pop @_ eq 'marcflavour'); >- return 0; >-}); >- >+$module->mock( >+ '_new_dbh', >+ sub { >+ my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >+ || die "Cannot create handle: $DBI::errstr\n"; >+ return $dbh; >+ } >+); >+$module->mock( >+ 'preference', >+ sub { >+ return 'MARC21' if ( pop @_ eq 'marcflavour' ); >+ return 0; >+ } >+); > > # Mock data > my $auth = MARC::Record->new; >@@ -53,69 +58,70 @@ $auth->add_fields( > [ '450', ' ', ' ', a => 'Cookery' ], > ); > >-my $mockauthority = [ >- ['authtypecode','marcxml'], >- ['TOPIC', $auth->as_xml_record() ], >- ]; >+my $mockauthority = >+ [ [ 'authtypecode', 'marcxml' ], [ 'TOPIC', $auth->as_xml_record() ], ]; > >-my $dbh = C4::Context->dbh(); # since we mocked _new_dbh we get a mock handle >+my $dbh = C4::Context->dbh(); # since we mocked _new_dbh we get a mock handle > > my $bib = MARC::Record->new; > $bib->add_fields( > [ '245', '0', '4', a => 'The Ifrane cookbook' ], > [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ] >- ); >+); > > my $resultbib = MARC::Record->new; > $resultbib->add_fields( > [ '245', '0', '4', a => 'The Ifrane cookbook' ], > [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ], > [ '650', 'z', ' ', a => 'Cookery' ] >- ); >+); > >-my $processor = Koha::RecordProcessor->new( { filters => ( 'EmbedSeeFromHeadings' ) } ); >-is(ref($processor), 'Koha::RecordProcessor', 'Created record processor'); >-is(ref($processor->filters->[0]), 'Koha::Filter::MARC::EmbedSeeFromHeadings', 'Loaded EmbedSeeFromHeadings filter'); >+my $processor = >+ Koha::RecordProcessor->new( { filters => ('EmbedSeeFromHeadings') } ); >+is( ref($processor), 'Koha::RecordProcessor', 'Created record processor' ); >+is( >+ ref( $processor->filters->[0] ), >+ 'Koha::Filter::MARC::EmbedSeeFromHeadings', >+ 'Loaded EmbedSeeFromHeadings filter' >+); > > $dbh->{mock_add_resultset} = $mockauthority; > > my $result = $processor->process(undef); > >-is($result, undef, "Don't flip out when asked to process nothing"); >+is( $result, undef, "Don't flip out when asked to process nothing" ); > > $result = $processor->process($bib); > > my $history = $dbh->{mock_all_history}; >-is(scalar(@{$history}), 1, 'Correct number of statements executed') ; >+is( scalar( @{$history} ), 1, 'Correct number of statements executed' ); > $dbh->{mock_clear_history} = 1; > >-is_deeply($result, $resultbib, 'Inserted see-from heading to record'); >+is_deeply( $result, $resultbib, 'Inserted see-from heading to record' ); > > my @bibs; > $bib = MARC::Record->new; > $bib->add_fields( > [ '245', '0', '4', a => 'The Ifrane cookbook' ], > [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ] >- ); >+); > push @bibs, $bib; > $bib = MARC::Record->new; > $bib->add_fields( > [ '245', '0', '2', a => 'A story of great tragedy, and fish' ], >- [ '650', ' ', ' ', a => 'Fish', 9 => '5432' ] >- ); >+ [ '650', ' ', ' ', a => 'Fish', 9 => '5432' ] ); > push @bibs, $bib; > my @resultbibs; > push @resultbibs, $resultbib; > push @resultbibs, $bib; > >- > $dbh->{mock_add_resultset} = $mockauthority; > >-$result = $processor->process(\@bibs); >+$result = $processor->process( \@bibs ); > >-is(scalar(@$result), 2, 'Processed two records'); >+is( scalar(@$result), 2, 'Processed two records' ); > > $history = $dbh->{mock_all_history}; >-is(scalar(@{$history}), 2, 'Correct number of statements executed'); >+is( scalar( @{$history} ), 2, 'Correct number of statements executed' ); > >-is_deeply($result, \@resultbibs, 'Handled both records correctly'); >+is_deeply( $result, \@resultbibs, 'Handled both records correctly' ); >diff --git a/t/db_dependent/Koha_Authority.t b/t/db_dependent/Koha_Authority.t >index c437a41..08b01a5 100755 >--- a/t/db_dependent/Koha_Authority.t >+++ b/t/db_dependent/Koha_Authority.t >@@ -20,24 +20,25 @@ > use Modern::Perl; > > use C4::Context; >-use Test::More; >+use Test::More tests => 7; > > BEGIN { >- use_ok('Koha::DataObject::Authority'); >+ use_ok('Koha::DataObject::Authority'); > } > > my $record = MARC::Record->new; > > $record->add_fields( >- [ '001', '1234' ], >- [ '150', ' ', ' ', a => 'Cooking' ], >- [ '450', ' ', ' ', a => 'Cookery' ], >- ); >-my $authority = Koha::DataObject::Authority->new($record); >+ [ '001', '1234' ], >+ [ '150', ' ', ' ', a => 'Cooking' ], >+ [ '450', ' ', ' ', a => 'Cookery' ], >+); >+my $authority = Koha::DataObject::Authority->new( { marcrecord => $record } ); > >-is(ref($authority), 'Koha::DataObject::Authority', 'Created valid Koha::DataObject::Authority object'); >+is( ref($authority), 'Koha::DataObject::Authority', >+ 'Created valid Koha::DataObject::Authority object' ); > >-is_deeply($authority->record, $record, 'Saved record'); >+is_deeply( $authority->marcrecord, $record, 'Saved record' ); > > SKIP: > { >@@ -46,20 +47,20 @@ SKIP: > $sth->execute(); > > my $authid; >- for my $row ($sth->fetchrow_hashref) { >+ for my $row ( $sth->fetchrow_hashref ) { > $authid = $row->{'authid'}; > } > skip 'No authorities', 3 unless $authid; >- $authority = Koha::DataObject::Authority->get_from_authid($authid); >+ $authority = Koha::DataObject::Authority->new( { authid => $authid } ); > >- is(ref($authority), 'Koha::DataObject::Authority', 'Retrieved valid Koha::DataObject::Authority object'); >+ is( ref($authority), 'Koha::DataObject::Authority', >+ 'Retrieved valid Koha::DataObject::Authority object' ); > >- is($authority->authid, $authid, 'Object authid is correct'); >+ is( $authority->authid, $authid, 'Object authid is correct' ); > >- is($authority->record->field('001')->data(), $authid, 'Retrieved correct record'); >- >- $authority = Koha::DataObject::Authority->get_from_authid('alphabetsoup'); >- is($authority, undef, 'No invalid record is retrieved'); >+ is( $authority->marcrecord->field('001')->data(), >+ $authid, 'Retrieved correct record' ); > } > >-done_testing(); >+$authority = Koha::DataObject::Authority->new( { authid => 'alphabetsoup' } ); >+is( $authority, undef, 'No invalid record is retrieved' ); >-- >1.7.2.5
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 7417
:
11028
|
11253
|
11319
|
11362
|
11363
|
11364
|
11365
|
11366
|
11393
|
11419
|
11427
|
11441
|
11460
|
11465
|
12147
|
12148
|
12199
|
12200
|
12204