From 79f04950498d1c756228d7fe60441313cc55079b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 9 Sep 2020 16:31:07 +0200 Subject: [PATCH] Bug 26157: Correct two occurrences We don't want to hide the warnings for all tests --- t/db_dependent/Koha/Patron.t | 15 ++++++----- t/db_dependent/Koha/Patron/Relationship.t | 33 ++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index d2aff3353c..ffec081dfc 100644 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -64,12 +64,15 @@ subtest 'add_guarantor() tests' => sub { is( $guarantors->count, 1, 'No guarantors added' ); - $SIG{__WARN__} = sub {}; # FIXME: PrintError = 0 not working! - - throws_ok - { $patron_1->add_guarantor({ guarantor_id => $patron_2->borrowernumber, relationship => 'father2' }); } - 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship', - 'Exception is thrown for duplicated relationship'; + { + local *STDERR; + open STDERR, '>', '/dev/null'; + throws_ok + { $patron_1->add_guarantor({ guarantor_id => $patron_2->borrowernumber, relationship => 'father2' }); } + 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship', + 'Exception is thrown for duplicated relationship'; + close STDERR; + } $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/Koha/Patron/Relationship.t b/t/db_dependent/Koha/Patron/Relationship.t index 47b51f7190..380aaa2ea6 100644 --- a/t/db_dependent/Koha/Patron/Relationship.t +++ b/t/db_dependent/Koha/Patron/Relationship.t @@ -90,22 +90,23 @@ subtest 'store() tests' => sub { } ); - $SIG{__WARN__} = sub {}; # FIXME: PrintError = 0 not working! - - throws_ok - { $relationship_2->store; } - 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship', - 'Exception is thrown for duplicated relationship'; - - is( "$@", - "There already exists a relationship for the same guarantor (" - . $patron_2->borrowernumber - . ") and guarantee (" - . $patron_1->borrowernumber - . ") combination", - 'Exception stringified correctly' - ); - + { + local *STDERR; + open STDERR, '>', '/dev/null'; + throws_ok + { $relationship_2->store; } + 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship', + 'Exception is thrown for duplicated relationship'; + + is( "$@", + "There already exists a relationship for the same guarantor (" + . $patron_2->borrowernumber + . ") and guarantee (" + . $patron_1->borrowernumber + . ") combination", + 'Exception stringified correctly' + ); + } $schema->storage->txn_rollback; }; -- 2.20.1