diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index 70e8339687..56b13fd8e4 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -69,8 +69,8 @@ sub connect { return unless $notification_method eq 'STOMP'; - my $hostname = $ENV{KOHA_STOMP_HOSTNAME} // 'localhost'; - my $port = $ENV{KOHA_STOMP_PORT} // '61613'; + my $hostname = 'localhost'; + my $port = '61613'; my $config = C4::Context->config('message_broker'); my $credentials = { diff --git a/t/db_dependent/Koha/BackgroundJob.t b/t/db_dependent/Koha/BackgroundJob.t index 35f8fb4e7d..fbbeb7e106 100755 --- a/t/db_dependent/Koha/BackgroundJob.t +++ b/t/db_dependent/Koha/BackgroundJob.t @@ -22,6 +22,7 @@ use Encode; use Test::More tests => 6; use Test::MockModule; use Test::Exception; +use Test::Warn; use Koha::Database; use Koha::BackgroundJobs; @@ -299,16 +300,16 @@ subtest 'decoded_data() and set_encoded_data() tests' => sub { }; subtest 'decoded_data() and set_encoded_data() tests' => sub { - plan tests => 2; + plan tests => 3; - $ENV{KOHA_STOMP_HOSTNAME} = "not_localhost"; - $ENV{KOHA_STOMP_PORT} = "99999"; + t::lib::Mocks::mock_config( 'message_broker', { hostname => 'not_localhost', port => '99999' } ); t::lib::Mocks::mock_preference('JobsNotificationMethod', 'STOMP'); - my $job = Koha::BackgroundJob->connect(); + my $job; + warning_like { $job = Koha::BackgroundJob->connect() } qr{Cannot connect to broker}; is( $job, undef, "Return undef if unable to connect when using stomp" ); t::lib::Mocks::mock_preference('JobsNotificationMethod', 'polling'); $job = Koha::BackgroundJob->connect(); is( $job, undef, "Return undef if using polling" ); -} +};