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

(-)a/t/Koha.t (-5 / +38 lines)
Lines 25-31 use Module::Load::Conditional qw/check_install/; Link Here
25
25
26
BEGIN {
26
BEGIN {
27
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
27
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
28
        plan tests => 33;
28
        plan tests => 34;
29
    } else {
29
    } else {
30
        plan skip_all => "Need Test::DBIx::Class"
30
        plan skip_all => "Need Test::DBIx::Class"
31
    }
31
    }
Lines 38-52 use Test::DBIx::Class { Link Here
38
    connect_info => ['dbi:SQLite:dbname=:memory:','',''],
38
    connect_info => ['dbi:SQLite:dbname=:memory:','',''],
39
    connect_opts => { name_sep => '.', quote_char => '`', },
39
    connect_opts => { name_sep => '.', quote_char => '`', },
40
    fixture_class => '::Populate',
40
    fixture_class => '::Populate',
41
}, 'AuthorisedValue' ;
41
}, 'AuthorisedValue', 'Branch' ;
42
42
43
sub fixtures {
43
sub fixtures {
44
    my ( $data ) = @_;
44
    my ( $av, $libraries ) = @_;
45
    fixtures_ok [
45
    fixtures_ok [
46
        AuthorisedValue => [
46
        AuthorisedValue => [
47
            [ 'category', 'authorised_value' ],
47
            [ 'category', 'authorised_value' ],
48
            @$data,
48
            @$av,
49
        ],
49
        ],
50
        Branch => [
51
            ['branchcode', 'branchname'],
52
            @$libraries,
53
        ]
50
    ], 'add fixtures';
54
    ], 'add fixtures';
51
}
55
}
52
56
Lines 57-63 my $authorised_values = [ Link Here
57
    ['LOC', 'LOC'],
61
    ['LOC', 'LOC'],
58
    ['RELTERMS', 'RELTERMS'],
62
    ['RELTERMS', 'RELTERMS'],
59
];
63
];
60
fixtures($authorised_values);
64
my $libraries = [
65
    ['XXX_test', 'my branchname XXX'],
66
];
67
fixtures($authorised_values, $libraries);
61
68
62
is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
69
is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
63
is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
70
is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
Lines 117-120 is( C4::Koha::GetNormalizedISBN(), undef, 'GetNormalizedISBN should return undef Link Here
117
is( C4::Koha::GetNormalizedEAN(), undef, 'GetNormalizedEAN should return undef if no record and no isbn are passed' );
124
is( C4::Koha::GetNormalizedEAN(), undef, 'GetNormalizedEAN should return undef if no record and no isbn are passed' );
118
is( C4::Koha::GetNormalizedOCLCNumber(), undef, 'GetNormalizedOCLCNumber should return undef if no record and no isbn are passed' );
125
is( C4::Koha::GetNormalizedOCLCNumber(), undef, 'GetNormalizedOCLCNumber should return undef if no record and no isbn are passed' );
119
126
127
subtest 'getFacets() tests' => sub {
128
    plan tests => 5;
129
130
    is ( Koha::Libraries->search->count, 1, 'There should be only 1 library (singleBranchMode on)' );
131
    my $facets = C4::Koha::getFacets();
132
    is(
133
        scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ),
134
        1,
135
        'location facet present with singleBranchMode on (bug 10078)'
136
    );
137
138
    $libraries = [
139
        ['YYY_test', 'my branchname YYY'],
140
        ['ZZZ_test', 'my branchname XXX'],
141
    ];
142
    fixtures($authorised_values, $libraries);
143
    is ( Koha::Libraries->search->count, 3, 'There should be only more than 1 library (singleBranchMode off)' );
144
145
    $facets = C4::Koha::getFacets();
146
    is(
147
        scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ),
148
        1,
149
        'location facet present with singleBranchMode off (bug 10078)'
150
    );
151
};
152
120
1;
153
1;
(-)a/t/db_dependent/Koha.t (-21 / +1 lines)
Lines 8-14 use C4::Context; Link Here
8
use Koha::DateUtils qw(dt_from_string);
8
use Koha::DateUtils qw(dt_from_string);
9
use Koha::AuthorisedValue;
9
use Koha::AuthorisedValue;
10
10
11
use Test::More tests => 10;
11
use Test::More tests => 9;
12
use DateTime::Format::MySQL;
12
use DateTime::Format::MySQL;
13
13
14
BEGIN {
14
BEGIN {
Lines 258-282 subtest 'ISBN tests' => sub { Link Here
258
258
259
};
259
};
260
260
261
subtest 'getFacets() tests' => sub {
262
    plan tests => 2;
263
264
    C4::Context->set_preference('singleBranchMode', 0);
265
    my $facets = C4::Koha::getFacets();
266
    is(
267
        scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ),
268
        1,
269
        'location facet present with singleBranchMode off (bug 10078)'
270
    );
271
    C4::Context->set_preference('singleBranchMode', 1);
272
    $facets = C4::Koha::getFacets();
273
    is(
274
        scalar( grep { defined $_->{idx} && $_->{idx} eq 'location' } @$facets ),
275
        1,
276
        'location facet present with singleBranchMode on (bug 10078)'
277
    );
278
};
279
280
subtest 'GetFrameworksLoop() tests' => sub {
261
subtest 'GetFrameworksLoop() tests' => sub {
281
    plan tests => 6;
262
    plan tests => 6;
282
263
283
- 

Return to bug 4941