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

(-)a/Koha/Libraries.pm (+18 lines)
Lines 64-69 sub search_filtered { Link Here
64
    return $self->SUPER::search( $params, $attributes );
64
    return $self->SUPER::search( $params, $attributes );
65
}
65
}
66
66
67
=head3 single_library_mode
68
69
    Aka singleBranchMode.
70
71
    my $boolean = Koha::Libraries->single_library_mode;
72
73
    Returns 1 if there is only one library marked public.
74
75
=cut
76
77
sub single_library_mode { # formerly called singleBranchMode
78
    my $self = shift;
79
    if( $self->search({ public => 1 })->count == 1 ) { # Historically we test number==1 instead of number<2
80
        return 1;
81
    }
82
    return 0;
83
}
84
67
=head3 type
85
=head3 type
68
86
69
=cut
87
=cut
(-)a/t/db_dependent/Koha/Libraries.t (-2 / +15 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 12;
22
use Test::More tests => 13;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Context;
25
use C4::Context;
Lines 365-367 subtest 'outgoing_transfers' => sub { Link Here
365
365
366
    $schema->storage->txn_rollback;
366
    $schema->storage->txn_rollback;
367
};
367
};
368
- 
368
369
subtest 'single_library_mode aka singleBranchMode' => sub {
370
    plan tests => 3;
371
    $schema->storage->txn_begin;
372
373
    Koha::Libraries->new->update({ public => 0 });
374
    is( Koha::Libraries->single_library_mode, 0, 'No public libraries' );
375
    my $library1 = $builder->build_object({ class => 'Koha::Libraries', value => { public => 1 } });
376
    is( Koha::Libraries->single_library_mode, 1, 'One public library' );
377
    my $library2 = $builder->build_object({ class => 'Koha::Libraries', value => { public => 1 } });
378
    is( Koha::Libraries->single_library_mode, 0, 'Two public libraries' );
379
380
    $schema->storage->txn_rollback;
381
};

Return to bug 31784