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

(-)a/t/db_dependent/Koha.t (-4 / +83 lines)
Lines 11-27 use Koha::DateUtils qw(dt_from_string); Link Here
11
use Test::More tests => 6;
11
use Test::More tests => 6;
12
use DateTime::Format::MySQL;
12
use DateTime::Format::MySQL;
13
13
14
eval {use Test::Deep;};
15
16
BEGIN {
14
BEGIN {
17
    use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote ));
15
    use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote ));
18
    use_ok('C4::Members');
16
    use_ok('C4::Members');
19
}
17
}
20
18
21
my $dbh = C4::Context->dbh;
19
my $dbh = C4::Context->dbh;
20
$dbh->{AutoCommit} = 0;
21
$dbh->{RaiseError} = 1;
22
22
23
subtest 'Authorized Values Tests' => sub {
23
subtest 'Authorized Values Tests' => sub {
24
    plan tests => 6;
24
    plan tests => 8;
25
25
26
    my $data = {
26
    my $data = {
27
        category            => 'CATEGORY',
27
        category            => 'CATEGORY',
Lines 60-65 subtest 'Authorized Values Tests' => sub { Link Here
60
        my $sth = $dbh->prepare($query);
60
        my $sth = $dbh->prepare($query);
61
        $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
61
        $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
62
    }
62
    }
63
64
    SKIP: {
65
        eval { require Test::Deep; import Test::Deep; };
66
        skip "Test::Deep required to run the GetAuthorisedValues() tests.", 2 if $@;
67
        AddAuthorisedValue('BUG10656', 'ZZZ', 'Z_STAFF', 'A_PUBLIC', '');
68
        AddAuthorisedValue('BUG10656', 'AAA', 'A_STAFF', 'Z_PUBLIC', '');
69
        # the next one sets lib_opac to NULL; in that case, the staff
70
        # display value is meant to be used.
71
        AddAuthorisedValue('BUG10656', 'DDD', 'D_STAFF', undef, '');
72
        my $authvals = GetAuthorisedValues('BUG10656');
73
        cmp_deeply(
74
            $authvals,
75
            [
76
                {
77
                    id => ignore(),
78
                    category => 'BUG10656',
79
                    authorised_value => 'AAA',
80
                    selected => 0,
81
                    lib => 'A_STAFF',
82
                    lib_opac => 'Z_PUBLIC',
83
                    imageurl => '',
84
                },
85
                {
86
                    id => ignore(),
87
                    category => 'BUG10656',
88
                    authorised_value => 'DDD',
89
                    selected => 0,
90
                    lib => 'D_STAFF',
91
                    lib_opac => undef,
92
                    imageurl => '',
93
                },
94
                {
95
                    id => ignore(),
96
                    category => 'BUG10656',
97
                    authorised_value => 'ZZZ',
98
                    selected => 0,
99
                    lib => 'Z_STAFF',
100
                    lib_opac => 'A_PUBLIC',
101
                    imageurl => '',
102
                },
103
            ],
104
            'list of authorised values in staff mode sorted by staff label (bug 10656)'
105
        );
106
        $authvals = GetAuthorisedValues('BUG10656', '', 1);
107
        cmp_deeply(
108
            $authvals,
109
            [
110
                {
111
                    id => ignore(),
112
                    category => 'BUG10656',
113
                    authorised_value => 'ZZZ',
114
                    selected => 0,
115
                    lib => 'A_PUBLIC',
116
                    lib_opac => 'A_PUBLIC',
117
                    imageurl => '',
118
                },
119
                {
120
                    id => ignore(),
121
                    category => 'BUG10656',
122
                    authorised_value => 'DDD',
123
                    selected => 0,
124
                    lib => 'D_STAFF',
125
                    lib_opac => undef,
126
                    imageurl => '',
127
                },
128
                {
129
                    id => ignore(),
130
                    category => 'BUG10656',
131
                    authorised_value => 'AAA',
132
                    selected => 0,
133
                    lib => 'Z_PUBLIC',
134
                    lib_opac => 'Z_PUBLIC',
135
                    imageurl => '',
136
                },
137
            ],
138
            'list of authorised values in OPAC mode sorted by OPAC label (bug 10656)'
139
        );
140
    }
141
    
63
};
142
};
64
143
65
subtest 'Itemtype info Tests' => sub {
144
subtest 'Itemtype info Tests' => sub {
Lines 85-90 subtest 'Itemtype info Tests' => sub { Link Here
85
### test for C4::Koha->GetDailyQuote()
164
### test for C4::Koha->GetDailyQuote()
86
SKIP:
165
SKIP:
87
    {
166
    {
167
        eval { require Test::Deep; import Test::Deep; };
88
        skip "Test::Deep required to run the GetDailyQuote tests.", 1 if $@;
168
        skip "Test::Deep required to run the GetDailyQuote tests.", 1 if $@;
89
169
90
        subtest 'Daily Quotes Test' => sub {
170
        subtest 'Daily Quotes Test' => sub {
91
- 

Return to bug 10656