Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
21 |
use Test::Exception; |
21 |
use Test::Exception; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 85-87
subtest "pagination_bar tests" => sub {
Link Here
|
85 |
is( @$PAGE_NUMBERS, 20, "If past first ten pages we show 20 pages" ); |
85 |
is( @$PAGE_NUMBERS, 20, "If past first ten pages we show 20 pages" ); |
86 |
|
86 |
|
87 |
}; |
87 |
}; |
88 |
- |
88 |
|
|
|
89 |
subtest "post_filter_opac_facets" => sub { |
90 |
plan tests => 4; |
91 |
|
92 |
my $facets = _get_mock_facet_data(); |
93 |
my $rules = { 'itype' => ['MP'] }; |
94 |
|
95 |
my $filtered_facets = Koha::SearchEngine::Search->post_filter_opac_facets( { facets => $facets, rules => $rules } ); |
96 |
is( scalar @$filtered_facets, 2, 'Facet type length the same' ); |
97 |
is( scalar @{ $filtered_facets->[0]->{facets} }, 3, 'author facet length the same' ); |
98 |
is( scalar @{ $filtered_facets->[1]->{facets} }, 1, 'itype facet has been filtered' ); |
99 |
is( $filtered_facets->[1]->{facets}->[0]->{facet_link_value}, 'BK', 'correct itype facet has been filtered' ); |
100 |
}; |
101 |
|
102 |
sub _get_mock_facet_data { |
103 |
my $facets = [ |
104 |
{ |
105 |
'type_label_Authors' => 1, |
106 |
'facets' => [ |
107 |
{ |
108 |
'facet_link_value' => 'Farley, David', |
109 |
'type_link_value' => 'author', |
110 |
'facet_title_value' => 'Farley, David', |
111 |
'facet_count' => 1, |
112 |
'facet_label_value' => 'Farley, David' |
113 |
}, |
114 |
{ |
115 |
'facet_label_value' => 'Humble, Jez', |
116 |
'facet_count' => 1, |
117 |
'facet_title_value' => 'Humble, Jez', |
118 |
'type_link_value' => 'author', |
119 |
'facet_link_value' => 'Humble, Jez' |
120 |
}, |
121 |
{ |
122 |
'facet_count' => 1, |
123 |
'facet_title_value' => 'Martin, Robert C.', |
124 |
'facet_label_value' => 'Martin, Robert C.', |
125 |
'type_link_value' => 'author', |
126 |
'facet_link_value' => 'Martin, Robert C.' |
127 |
} |
128 |
], |
129 |
'av_cat' => '', |
130 |
'order' => 1, |
131 |
'label' => 'Authors', |
132 |
'type_id' => 'author_id', |
133 |
'type_link_value' => 'author' |
134 |
}, |
135 |
{ |
136 |
'type_label_Item types' => 1, |
137 |
'facets' => [ |
138 |
{ |
139 |
'type_link_value' => 'itype', |
140 |
'facet_link_value' => 'BK', |
141 |
'facet_count' => 4, |
142 |
'facet_title_value' => 'BK', |
143 |
'facet_label_value' => 'Books' |
144 |
}, |
145 |
{ |
146 |
'facet_title_value' => 'MP', |
147 |
'facet_count' => 1, |
148 |
'facet_label_value' => 'Maps', |
149 |
'type_link_value' => 'itype', |
150 |
'facet_link_value' => 'MP' |
151 |
} |
152 |
], |
153 |
'order' => 2, |
154 |
'av_cat' => undef, |
155 |
'type_id' => 'itype_id', |
156 |
'type_link_value' => 'itype', |
157 |
'label' => 'Item types' |
158 |
} |
159 |
]; |
160 |
} |