We must redirect them to /dev/null if we know they will appear.
Test plan:
prove the different test files and confirm that the output is clean when
this patch is applied
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
); } 'Koha::Exceptions::Account::AmountNotPositive', 'Expected validation exception thrown (amount)';
throws_ok {
- $account->add_debit(
- {
- amount => 5,
- description => 'type validation failure',
- library_id => $patron->branchcode,
- note => 'this should fail anyway',
- type => 'failure',
- user_id => $patron->id,
- interface => 'commandline'
- }
- ); } 'Koha::Exceptions::Account::UnrecognisedType', 'Expected validation exception thrown (type)';
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ $account->add_debit(
+ {
+ amount => 5,
+ description => 'type validation failure',
+ library_id => $patron->branchcode,
+ note => 'this should fail anyway',
+ type => 'failure',
+ user_id => $patron->id,
+ interface => 'commandline'
+ }
+ );
+ close STDERR;
+ }
+ 'Koha::Exceptions::Account::UnrecognisedType',
+ 'Expected validation exception thrown (type)';
throws_ok {
$account->add_debit(
my $deleted_id = $patron_to_delete->id;
$patron_to_delete->delete;
- throws_ok
- { Koha::ApiKey->new({ patron_id => $deleted_id, description => 'a description' })->store }
+ { # hide useless warnings
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ throws_ok {
+ Koha::ApiKey->new(
+ { patron_id => $deleted_id, description => 'a description' } )
+ ->store
+ }
'Koha::Exceptions::Object::FKConstraint',
- 'Invalid patron ID raises exception';
+ 'Invalid patron ID raises exception';
+ close STDERR;
+ }
is( $@->message, 'Broken FK constraint', 'Exception message is correct' );
is( $@->broken_fk, 'patron_id', 'Exception field is correct' );
my $dbh = $schema->storage->dbh;
{
- local $dbh->{PrintError} = 0;
- local $dbh->{RaiseError} = 0;
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
throws_ok
{ $api_key->store }
'Koha::Exceptions::Object::FKConstraint',
qr/(api_keys\.)?secret/,
'Exception field is correct (note that MySQL 8 is displaying the tablename)'
);
+ close STDERR;
}
# Successful test
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
+
try {
- local $schema->storage->dbh->{RaiseError} = 0;
- local $schema->storage->dbh->{PrintError} = 0;
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
$patron->lastseen('wrong_value')->store;
+ close STDERR;
} catch {
ok( $_->isa('Koha::Exceptions::Object::BadValue'), 'Exception thrown correctly' );
like( $_->property, qr/(borrowers\.)?lastseen/, 'Column should be the expected one' ); # The table name is not always displayed, it depends on the DBMS version
my $patron_1 = $builder->build_object({class=> 'Koha::Patrons'});
my $patron_2 = $builder->build_object({class=> 'Koha::Patrons'});
- throws_ok
- { $patron_2->userid($patron_1->userid)->store; }
+ {
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ throws_ok { $patron_2->userid( $patron_1->userid )->store; }
'Koha::Exceptions::Object::DuplicateID',
- 'Koha::Patron->store raises an exception on duplicate ID';
+ 'Koha::Patron->store raises an exception on duplicate ID';
+ close STDERR;
+ }
# Test password
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
"The suggestion is not deleted when the related branch is deleted" );
# managerid
- throws_ok { $suggestion->managedby($nonexistent_borrowernumber)->store; }
- 'Koha::Exceptions::Object::FKConstraint',
- 'store raises an exception on invalid managerid';
+ { # hide useless warnings
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ throws_ok {
+ $suggestion->managedby($nonexistent_borrowernumber)->store;
+ }
+ 'Koha::Exceptions::Object::FKConstraint',
+ 'store raises an exception on invalid managerid';
+ close STDERR;
+ }
my $manager = $builder->build_object( { class => "Koha::Patrons" } );
$suggestion->managedby( $manager->borrowernumber )->store;
$manager->delete;
"The suggestion is not deleted when the related manager is deleted" );
# acceptedby
- throws_ok { $suggestion->acceptedby($nonexistent_borrowernumber)->store; }
- 'Koha::Exceptions::Object::FKConstraint',
- 'store raises an exception on invalid acceptedby id';
+ { # hide useless warnings
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ throws_ok {
+ $suggestion->acceptedby($nonexistent_borrowernumber)->store;
+ }
+ 'Koha::Exceptions::Object::FKConstraint',
+ 'store raises an exception on invalid acceptedby id';
+ close STDERR;
+ }
my $acceptor = $builder->build_object( { class => "Koha::Patrons" } );
$suggestion->acceptedby( $acceptor->borrowernumber )->store;
$acceptor->delete;
"The suggestion is not deleted when the related acceptor is deleted" );
# rejectedby
- throws_ok { $suggestion->rejectedby($nonexistent_borrowernumber)->store; }
- 'Koha::Exceptions::Object::FKConstraint',
- 'store raises an exception on invalid rejectedby id';
+ { # hide useless warnings
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+ throws_ok {
+ $suggestion->rejectedby($nonexistent_borrowernumber)->store;
+ }
+ 'Koha::Exceptions::Object::FKConstraint',
+ 'store raises an exception on invalid rejectedby id';
+ close STDERR;
+ }
my $rejecter = $builder->build_object( { class => "Koha::Patrons" } );
$suggestion->rejectedby( $rejecter->borrowernumber )->store;
$rejecter->delete;
"The suggestion is not deleted when the related rejecter is deleted" );
# budgetid
- throws_ok { $suggestion->budgetid($nonexistent_borrowernumber)->store; }
- 'Koha::Exceptions::Object::FKConstraint',
- 'store raises an exception on invalid budgetid';
+ { # hide useless warnings
+ local *STDERR;
+ open STDERR, '>', '/dev/null';
+
+ throws_ok { $suggestion->budgetid($nonexistent_borrowernumber)->store; }
+ 'Koha::Exceptions::Object::FKConstraint',
+ 'store raises an exception on invalid budgetid';
+ close STDERR;
+ }
my $fund = $builder->build_object( { class => "Koha::Acquisition::Funds" } );
$suggestion->budgetid( $fund->id )->store;
$fund->delete;