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

(-)a/t/db_dependent/Illrequests.t (-2 / +43 lines)
Lines 376-382 subtest 'Backend testing (mocks)' => sub { Link Here
376
376
377
subtest 'Backend core methods' => sub {
377
subtest 'Backend core methods' => sub {
378
378
379
    plan tests => 17;
379
    plan tests => 19;
380
380
381
    $schema->storage->txn_begin;
381
    $schema->storage->txn_begin;
382
382
Lines 384-389 subtest 'Backend core methods' => sub { Link Here
384
    my $backend = Test::MockObject->new;
384
    my $backend = Test::MockObject->new;
385
    $backend->set_isa('Koha::Illbackends::Mock');
385
    $backend->set_isa('Koha::Illbackends::Mock');
386
    $backend->set_always('name', 'Mock');
386
    $backend->set_always('name', 'Mock');
387
    $backend->mock('capabilities', sub { return 'Mock'; });
387
388
388
    my $config = Test::MockObject->new;
389
    my $config = Test::MockObject->new;
389
    $config->set_always('backend_dir', "/tmp");
390
    $config->set_always('backend_dir', "/tmp");
Lines 423-428 subtest 'Backend core methods' => sub { Link Here
423
    $backend->set_series('create',
424
    $backend->set_series('create',
424
                         { stage => 'bar', method => 'create' },
425
                         { stage => 'bar', method => 'create' },
425
                         { stage => 'commit', method => 'create' },
426
                         { stage => 'commit', method => 'create' },
427
                         { stage => 'commit', method => 'create' },
428
                         { stage => 'commit', method => 'create' },
426
                         { stage => 'commit', method => 'create' });
429
                         { stage => 'commit', method => 'create' });
427
    # Test non-commit
430
    # Test non-commit
428
    is_deeply($illrq->backend_create({test => 1}),
431
    is_deeply($illrq->backend_create({test => 1}),
Lines 452-457 subtest 'Backend core methods' => sub { Link Here
452
              "Backend create: arbitrary stage, permitted.");
455
              "Backend create: arbitrary stage, permitted.");
453
    is($illrq->status, "NEW", "Backend create: not-queued.");
456
    is($illrq->status, "NEW", "Backend create: not-queued.");
454
457
458
    # Test that enabling the unmediated workflow causes the backend's
459
    # 'unmediated_ill' method to be called
460
    t::lib::Mocks::mock_preference('ILLModuleUnmediated', '1');
461
    $backend->mock(
462
        'capabilities',
463
        sub {
464
            my ($self, $name) = @_;
465
            if ($name eq 'unmediated_ill') {
466
                return sub {
467
                    return { unmediated_ill => 1 };
468
                };
469
            }
470
        }
471
    );
472
    $illrq->status('NEW');
473
    is_deeply(
474
        $illrq->backend_create({test => 1}),
475
        {
476
            'opac_template' => '/tmp/Mock/opac-includes/.inc',
477
            'template' => '/tmp/Mock/intra-includes/.inc',
478
            'unmediated_ill' => 1
479
        },
480
        "Backend create: commit stage, permitted, ILLModuleUnmediated enabled."
481
    );
482
483
    # Test that disabling the unmediated workflow causes the backend's
484
    # 'unmediated_ill' method to be NOT called
485
    t::lib::Mocks::mock_preference('ILLModuleUnmediated', '0');
486
    $illrq->status('NEW');
487
    is_deeply(
488
        $illrq->backend_create({test => 1}),
489
        {
490
            stage => 'commit', method => 'create', permitted => 1,
491
            template => "/tmp/Mock/intra-includes/create.inc",
492
            opac_template => "/tmp/Mock/opac-includes/create.inc",
493
        },
494
        "Backend create: commit stage, permitted, ILLModuleUnmediated disabled."
495
    );
496
455
    # backend_renew
497
    # backend_renew
456
    $backend->set_series('renew', { stage => 'bar', method => 'renew' });
498
    $backend->set_series('renew', { stage => 'bar', method => 'renew' });
457
    is_deeply($illrq->backend_renew({test => 1}),
499
    is_deeply($illrq->backend_renew({test => 1}),
458
- 

Return to bug 18837