Bugzilla – Attachment 63731 Details for
Bug 18611
Create labels action fails in manage-marc-import.pl if an item has been deleted from the import batch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18611: [QA Follow-up] Add unit test for GetItemNumbersFromImportBatch
Bug-18611-QA-Follow-up-Add-unit-test-for-GetItemNu.patch (text/plain), 2.78 KB, created by
Marcel de Rooy
on 2017-05-26 08:27:40 UTC
(
hide
)
Description:
Bug 18611: [QA Follow-up] Add unit test for GetItemNumbersFromImportBatch
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-05-26 08:27:40 UTC
Size:
2.78 KB
patch
obsolete
>From dc0b64490b7982ecc093e3959fcbf2ab641a21dd Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 26 May 2017 10:25:10 +0200 >Subject: [PATCH] Bug 18611: [QA Follow-up] Add unit test for > GetItemNumbersFromImportBatch >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/ImportBatch.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/ImportBatch.t | 29 ++++++++++++++++++++++++----- > 1 file changed, 24 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 156b505..bdab996 100644 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -1,19 +1,20 @@ > #!/usr/bin/perl > > use Modern::Perl; >+use Test::More tests => 13; > >-use C4::Context; >- >-use Test::More tests => 9; >+use Koha::Database; >+use t::lib::TestBuilder; > > BEGIN { > use_ok('C4::ImportBatch'); > } > > # Start transaction >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; > > # clear > $dbh->do('DELETE FROM import_batches'); >@@ -118,6 +119,22 @@ my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImpo > $original_record->leader($record_from_import_biblio_without_items->leader()); > is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' ); > >+# Add a few tests for GetItemNumbersFromImportBatch >+my @a = GetItemNumbersFromImportBatch( $id_import_batch1 ); >+is( @a, 0, 'No item numbers expected since we did not commit' ); >+my $itemno = $builder->build({ source => 'Item' })->{itemnumber}; >+# Link this item to the import item to fool GetItemNumbersFromImportBatch >+my $sql = "UPDATE import_items SET itemnumber=? WHERE import_record_id=?"; >+$dbh->do( $sql, undef, $itemno, $import_record_id ); >+@a = GetItemNumbersFromImportBatch( $id_import_batch1 ); >+is( @a, 2, 'Expecting two items now' ); >+is( $a[0], $itemno, 'Check the first returned itemnumber' ); >+# Now delete the item and check again >+$dbh->do( "DELETE FROM items WHERE itemnumber=?", undef, $itemno ); >+@a = GetItemNumbersFromImportBatch( $id_import_batch1 ); >+is( @a, 0, 'No item numbers expected since we deleted the item' ); >+$dbh->do( $sql, undef, undef, $import_record_id ); # remove link again >+ > # fresh data > my $sample_import_batch3 = { > matcher_id => 3, >@@ -144,3 +161,5 @@ is( $batch3_clean, "0E0", "Batch 3 has been cleaned" ); > C4::ImportBatch::DeleteBatch( $id_import_batch3 ); > my $batch3_results = $dbh->do('SELECT * FROM import_batches WHERE import_batch_id = "$id_import_batch3"'); > is( $batch3_results, "0E0", "Batch 3 has been deleted"); >+ >+$schema->storage->txn_rollback; >-- >2.1.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 18611
:
63483
|
63667
|
63668
|
63669
|
63728
|
63729
|
63730
| 63731