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

(-)a/t/db_dependent/Koha/UI/Form/Builder/Item.t (-15 / +18 lines)
Lines 45-50 $cache->clear_from_cache("MarcSubfieldStructure-"); Link Here
45
# 952$t is linked with items.copynumber and is not repeatable
45
# 952$t is linked with items.copynumber and is not repeatable
46
setup_mss();
46
setup_mss();
47
47
48
# FIXME Later in this script we are comparing itemtypes, ordered by their description.
49
# MySQL and Perl don't sort _ identically.
50
# If you have one itemtype BK and another one B_K, MySQL will sort B_K first when Perl will sort it last
51
my @itemtypes = Koha::ItemTypes->search->as_list;
52
for my $itemtype ( @itemtypes ) {
53
    my $d = $itemtype->description;
54
    $d =~ s|_||g;
55
    $itemtype->description($d)->store;
56
}
57
48
subtest 'authorised values' => sub {
58
subtest 'authorised values' => sub {
49
    #plan tests => 1;
59
    #plan tests => 1;
50
60
Lines 111-139 subtest 'authorised values' => sub { Link Here
111
    subtest 'itemtypes' => sub {
121
    subtest 'itemtypes' => sub {
112
        plan tests => 2;
122
        plan tests => 2;
113
        my ($subfield) = grep { $_->{kohafield} eq 'items.itype' } @$subfields;
123
        my ($subfield) = grep { $_->{kohafield} eq 'items.itype' } @$subfields;
114
        my $itemtypes = Koha::ItemTypes->search;
124
        my @itemtypes = Koha::ItemTypes->search->as_list;
115
125
116
        my $expected = [
126
        my $expected = [
117
            "",
127
            "",
118
                map    { $_->itemtype }
128
            map    { $_->itemtype }
119
                  # We need to sort using uc or perl won't be case insensitive
129
              # We need to sort using uc or perl won't be case insensitive
120
                  sort { uc($a->translated_description) cmp uc($b->translated_description) }
130
              sort { uc($a->translated_description) cmp uc($b->translated_description) }
121
                  $itemtypes->as_list
131
              @itemtypes
122
            ];
132
        ];
123
        is_deeply(
133
        is_deeply(
124
            $subfield->{marc_value}->{values},
134
            $subfield->{marc_value}->{values},
125
            $expected,
135
            $expected,
126
            "Item types should be sorted by description and an empty entry should be shown"
136
            "Item types should be sorted by description and an empty entry should be shown"
127
        )
137
        );
128
        or diag("Itemtypes details: " . Dumper(
129
            $subfield->{marc_value}->{values},
130
            $expected,
131
            { map { $_->itemtype => $_->translated_description } $itemtypes->as_list },
132
            $Koha::Schema::Result::Itemtype::LANGUAGE,
133
        ));
134
138
135
        is_deeply( $subfield->{marc_value}->{labels},
139
        is_deeply( $subfield->{marc_value}->{labels},
136
            { map { $_->itemtype => $_->description } $itemtypes->as_list },
140
            { map { $_->itemtype => $_->description } @itemtypes},
137
            'Labels should be correctly displayed'
141
            'Labels should be correctly displayed'
138
        );
142
        );
139
    };
143
    };
140
- 

Return to bug 28445