View | Details | Raw Unified | Return to bug 34070
Collapse All | Expand All

(-)a/t/db_dependent/Koha/BackgroundJob.t (-11 / +29 lines)
Lines 303-319 subtest 'decoded_data() and set_encoded_data() tests' => sub { Link Here
303
    $schema->storage->txn_rollback;
303
    $schema->storage->txn_rollback;
304
};
304
};
305
305
306
subtest 'decoded_data() and set_encoded_data() tests' => sub {
306
subtest 'connect' => sub {
307
    plan tests => 3;
307
    plan tests => 2;
308
309
    subtest 'JobsNotificationMethod' => sub {
310
        plan tests => 3;
311
        t::lib::Mocks::mock_config( 'message_broker', { hostname => 'not_localhost', port => '99999' } );
312
313
        t::lib::Mocks::mock_preference( 'JobsNotificationMethod', 'STOMP' );
314
        my $job;
315
        warning_like { $job = Koha::BackgroundJob->connect() } qr{Cannot connect to broker};
316
        is( $job, undef, "Return undef if unable to connect when using stomp" );
308
317
309
    t::lib::Mocks::mock_config( 'message_broker', { hostname => 'not_localhost', port => '99999' } );
318
        t::lib::Mocks::mock_preference( 'JobsNotificationMethod', 'polling' );
319
        $job = Koha::BackgroundJob->connect();
320
        is( $job, undef, "Return undef if using polling" );
321
    };
322
323
    subtest 'wrong credentials' => sub {
324
        plan tests => 2;
325
        t::lib::Mocks::mock_preference( 'JobsNotificationMethod', 'STOMP' );
310
326
311
    t::lib::Mocks::mock_preference( 'JobsNotificationMethod', 'STOMP' );
327
        t::lib::Mocks::mock_config(
312
    my $job;
328
            'message_broker',
313
    warning_like { $job = Koha::BackgroundJob->connect() } qr{Cannot connect to broker};
329
            { hostname => 'localhost', port => '61613', username => 'guest', password => 'wrong_password' }
314
    is( $job, undef, "Return undef if unable to connect when using stomp" );
330
        );
315
331
316
    t::lib::Mocks::mock_preference( 'JobsNotificationMethod', 'polling' );
332
        my $job;
317
    $job = Koha::BackgroundJob->connect();
333
        warning_is { $job = Koha::BackgroundJob->connect() }
318
    is( $job, undef, "Return undef if using polling" );
334
        q{Cannot connect to broker (Access refused for user 'guest')};
335
        is( $job, undef, "Return undef if unable to connect when using stomp" );
336
337
    };
319
};
338
};
320
- 

Return to bug 34070