Bugzilla – Attachment 18384 Details for
Bug 10333
UT: Labels/t_Batch.t needs to create its own data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10333: Labels/t_Batch.t needs to create its own data
Bug-10333-LabelstBatcht-needs-to-create-its-own-da.patch (text/plain), 4.08 KB, created by
Jonathan Druart
on 2013-05-24 12:53:56 UTC
(
hide
)
Description:
Bug 10333: Labels/t_Batch.t needs to create its own data
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-05-24 12:53:56 UTC
Size:
4.08 KB
patch
obsolete
>From fbfb95aa801c89fa8706a5576c8b0cc0346602e8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 24 May 2013 14:51:14 +0200 >Subject: [PATCH] Bug 10333: Labels/t_Batch.t needs to create its own data > >prove t/db_dependent/Labels/t_Batch.t >[14:53:09] >t/db_dependent/Labels/t_Batch.t .. 1/32 # Testing Batch->new() method. >t/db_dependent/Labels/t_Batch.t .. 13/32 # Testing Batch->retrieve() >method. >t/db_dependent/Labels/t_Batch.t .. ok >All tests successful. >Files=1, Tests=32, 3 wallclock secs ( 0.02 usr 0.00 sys + 0.48 cusr >0.03 csys = 0.53 CPU) >Result: PASS >--- > t/db_dependent/Labels/t_Batch.t | 53 ++++++++++++++++++++++++++++++--------- > 1 file changed, 41 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/Labels/t_Batch.t b/t/db_dependent/Labels/t_Batch.t >index b61f4de..aff60e4 100644 >--- a/t/db_dependent/Labels/t_Batch.t >+++ b/t/db_dependent/Labels/t_Batch.t >@@ -3,7 +3,7 @@ > # Copyright 2007 Foundations Bible College. > # > # 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 2 of the License, or (at your option) any later >@@ -17,12 +17,14 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More tests => 23; >+use Test::More tests => 32; > use C4::Context; >-use Data::Dumper; >+use MARC::Record; >+use MARC::Field; >+use C4::Biblio; >+use C4::Items; > > BEGIN { > use_ok('C4::Labels::Batch'); >@@ -58,13 +60,29 @@ foreach my $key (keys %{$expected_batch}) { > } > } > >+ > diag "Testing Batch->add_item() method."; >-my $sth1 = C4::Context->dbh->prepare('SELECT itemnumber FROM items LIMIT 0,10'); >-$sth1->execute(); >-while (my $row = $sth1->fetchrow_hashref()) { >- diag sprintf('Database returned the following error: %s', $sth1->errstr) if $sth1->errstr; >- ok($batch->add_item($row->{'itemnumber'}) eq 0 ) || diag "Batch->add_item() FAILED."; >- $item_number = $row->{'itemnumber'}; >+# Create the item >+my $record = MARC::Record->new(); >+$record->append_fields( >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+ MARC::Field->new( '952', '', '', a => 'CPL', b => 'CPL' ), >+); >+my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); >+my @iteminfo = C4::Items::AddItemBatchFromMarc( $record, $biblionumber, $biblioitemnumber, '' ); >+ >+my $itemnumbers = $iteminfo[0]; >+ >+for my $itemnumber ( @$itemnumbers ) { >+ ok($batch->add_item($itemnumber) eq 0 ) || diag "Batch->add_item() FAILED."; > } > > diag "Testing Batch->retrieve() method."; >@@ -73,7 +91,10 @@ is_deeply($saved_batch, $batch) || diag "Retrieved batch object FAILED to verify > > diag "Testing Batch->remove_item() method."; > >-ok($batch->remove_item($item_number) eq 0) || diag "Batch->remove_item() FAILED."; >+for my $itemnumber ( @$itemnumbers ) { >+ ok($batch->remove_item($itemnumber) eq 0) || diag "Batch->remove_item() FAILED."; >+} >+ > my $updated_batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); > is_deeply($updated_batch, $batch) || diag "Updated batch object FAILED to verify."; > >@@ -81,3 +102,11 @@ diag "Testing Batch->delete() method."; > > my $del_results = $batch->delete(); > ok($del_results eq 0) || diag "Batch->delete() FAILED."; >+ >+END { >+ my $dbh = C4::Context->dbh; >+ for my $itemnumber ( @$itemnumbers ) { >+ C4::Items::DelItem( $dbh, $biblionumber, $itemnumber); >+ } >+ C4::Biblio::DelBiblio($biblionumber); >+}; >-- >1.7.10.4
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 10333
:
18384
|
18399
|
19201
|
20276
|
20454
|
20593