From 8d0bef561eb96f3f758eca719c2b891fe181b8af Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 19 Apr 2017 12:15:46 -0300 Subject: [PATCH] Bug 18460: Fix undefined itemtype warning in Serials.t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch makes the test create an itemtype, and use it for the created item so there's no warning. To test: - Run: $ prove t/db_dependent/Serials.t => FAIL: item-level_itypes set but no itemtype set... warning raised - Apply the patch - Run: $ prove t/db_dependent/Serials.t => SUCCESS: Tests pass and no warning is raised - Sign off :-D https://bugs.koha-community.org/show_bug.cgi?id=18361 Signed-off-by: Marc VĂ©ron --- t/db_dependent/Serials.t | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index dc6edd3..be7f010 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -17,6 +17,7 @@ use C4::Items; use Koha::DateUtils; use Koha::Acquisition::Booksellers; use t::lib::Mocks; +use t::lib::TestBuilder; use Test::More tests => 49; BEGIN { @@ -29,6 +30,8 @@ my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; +my $builder = t::lib::TestBuilder->new(); + # This could/should be used for all untested methods my @methods = ('updateClaim'); can_ok('C4::Serials', @methods); @@ -140,17 +143,33 @@ ok(C4::Serials::GetSerialStatusFromSerialId($serial->{serialid}), 'test getting isa_ok(C4::Serials::GetSerialInformation($serial->{serialid}), 'HASH', 'test getting Serial Information'); subtest 'Values should not be erased on editing' => sub { + plan tests => 1; + ( $biblionumber, $biblioitemnumber ) = get_biblio(); my ( $icn_tag, $icn_sf ) = GetMarcFromKohaField( 'items.itemcallnumber', '' ); - my $item_record = new MARC::Record; + my ( $it_tag, $it_sf ) = GetMarcFromKohaField( 'items.itype', '' ); + + my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; my $itemcallnumber = 'XXXmy itemcallnumberXXX'; - $item_record->append_fields( MARC::Field->new( '080', '', '', "a" => "default" ), MARC::Field->new( $icn_tag, '', '', $icn_sf => $itemcallnumber ), ); + + my $item_record = new MARC::Record; + + $item_record->append_fields( + MARC::Field->new( '080', '', '', "a" => "default" ), + MARC::Field->new( + $icn_tag, '', '', + $icn_sf => $itemcallnumber, + $it_sf => $itemtype + ) + ); my ( undef, undef, $itemnumber ) = C4::Items::AddItemFromMarc( $item_record, $biblionumber ); - my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber, 1, undef, undef, "publisheddatetext", "notes" ); + my $serialid = C4::Serials::NewIssue( "serialseq", $subscriptionid, $biblionumber, + 1, undef, undef, "publisheddatetext", "notes" ); C4::Serials::AddItem2Serial( $serialid, $itemnumber ); my $serial_info = C4::Serials::GetSerialInformation($serialid); - my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' } @{ $serial_info->{items}[0]->{iteminformation} }; + my ($itemcallnumber_info) = grep { $_->{kohafield} eq 'items.itemcallnumber' } + @{ $serial_info->{items}[0]->{iteminformation} }; like( $itemcallnumber_info->{marc_value}, qr|value="$itemcallnumber"| ); }; -- 2.1.4