Bugzilla – Attachment 94100 Details for
Bug 23038
Expected warnings displayed by tests should be hidden
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23038: Hide expected warnings from tests
Bug-23038-Hide-expected-warnings-from-tests.patch (text/plain), 3.46 KB, created by
Katrin Fischer
on 2019-10-14 20:13:51 UTC
(
hide
)
Description:
Bug 23038: Hide expected warnings from tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-10-14 20:13:51 UTC
Size:
3.46 KB
patch
obsolete
>From 7e85eb51ccdb95c55ef2493495a7b548687952da Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 3 Jun 2019 11:40:31 -0500 >Subject: [PATCH] Bug 23038: Hide expected warnings from tests > >When tests are ran, there are 2 warnings that are expected and raised by >DBI. >As they are expected they must be correctly caught and not displayed. > >We could have reconnect with PrintError turned off, but then reconnect >with it on. > >Test plan: >% prove t/db_dependent/Circulation/MarkIssueReturned.t t/db_dependent/Suggestions.t >Must not display DBI warnings > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Circulation/MarkIssueReturned.t | 16 ++++++++++++---- > t/db_dependent/Suggestions.t | 22 ++++++++++++++++------ > 2 files changed, 28 insertions(+), 10 deletions(-) > >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index 70924bca39..6544ffbb65 100644 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -174,10 +174,18 @@ subtest 'Manually pass a return date' => sub { > > $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); > >- throws_ok >- { $issue_id = C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, 'bad_date', 0 ); } >- 'Koha::Exceptions::Object::BadValue', >- 'An exception is thrown on bad date'; >+ { >+ # Hiding the expected warning displayed by DBI >+ # DBD::mysql::st execute failed: Incorrect datetime value: 'bad_date' for column 'returndate' >+ my $stderr; >+ local *STDERR; >+ open STDERR, '>', '/dev/null'; >+ throws_ok >+ { $issue_id = C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, 'bad_date', 0 ); } >+ 'Koha::Exceptions::Object::BadValue', >+ 'An exception is thrown on bad date'; >+ close STDERR; >+ } > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 96ebc8d234..c96c142f16 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -250,12 +250,22 @@ $messages = C4::Letters::GetQueuedMessages({ > }); > is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEmail syspref is enabled the suggestion message_transport_type is email if the borrower has an email'); > >-$mod_suggestion4->{manageddate} = 'invalid date!'; >-ModSuggestion($mod_suggestion4); >-$messages = C4::Letters::GetQueuedMessages({ >- borrowernumber => $borrowernumber2 >-}); >-is (scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error'); >+{ >+ # Hiding the expected warning displayed by DBI >+ # DBD::mysql::st execute failed: Incorrect date value: 'invalid date!' for column 'manageddate' >+ my $stderr; >+ local *STDERR; >+ open STDERR, '>', '/dev/null'; >+ >+ $mod_suggestion4->{manageddate} = 'invalid date!'; >+ ModSuggestion($mod_suggestion4); >+ $messages = C4::Letters::GetQueuedMessages({ >+ borrowernumber => $borrowernumber2 >+ }); >+ >+ close STDERR; >+ is (scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error'); >+} > > is( GetSuggestionInfo(), undef, 'GetSuggestionInfo without the suggestion id returns undef' ); > $suggestion = GetSuggestionInfo($my_suggestionid); >-- >2.11.0
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 23038
:
90278
|
90678
|
94041
| 94100 |
94101