Bug 19070: Fix Circulation/Branch.t

Resolve:
DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha_master`.`clubs`, CONSTRAINT `clubs_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) [for Statement "DELETE FROM branches"] at t/db_dependent/Circulation/Branch.t line 49.

Resolve:
not ok 14 - AddReturn respects branch item return policy - noreturn
   Failed test 'AddReturn respects branch item return policy - noreturn'
   at t/db_dependent/Circulation/Branch.t line 279.
          got: 'yqiKrIkX'
     expected: undef

Cause:
There is a record in clubs. The constraint in clubs on branchcode does not
include a cascaded delete. The test deletes all branches.
Test 14 depends on item-level_itypes==1. When you set it to Biblio, it fails.

Test plan:
Run t/db_dependent/Circulation/Branch.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2017-08-10 09:04:16 +02:00 committed by Jonathan Druart
parent 8a328a20bf
commit d2cceb95b4

View file

@ -46,6 +46,7 @@ my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM items|);
$dbh->do(q|DELETE FROM borrowers|);
$dbh->do(q|DELETE FROM clubs|);
$dbh->do(q|DELETE FROM branches|);
$dbh->do(q|DELETE FROM categories|);
$dbh->do(q|DELETE FROM accountlines|);
@ -270,9 +271,11 @@ is( $messages->{NeedsTransfer}, $samplebranch1->{branchcode}, "AddReturn respect
$query =
"INSERT INTO issues (borrowernumber,itemnumber,branchcode) VALUES( ?,?,? )";
$dbh->do( $query, {}, $borrower_id1, $item_id3, $samplebranch1->{branchcode} );
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_3',
$samplebranch1->{branchcode});
is($messages->{NeedsTransfer},undef,"AddReturn respects branch item return policy - noreturn");
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
$schema->storage->txn_rollback;