Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use MARC::Record; |
20 |
use MARC::Record; |
21 |
use Test::More tests => 4; |
21 |
use Test::More tests => 5; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
Lines 213-215
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
Link Here
|
213 |
|
213 |
|
214 |
$schema->storage->txn_rollback; |
214 |
$schema->storage->txn_rollback; |
215 |
}; |
215 |
}; |
216 |
- |
216 |
|
|
|
217 |
subtest 'XSLTParse4Display and show_analytics_link' => sub { |
218 |
plan tests => 4; |
219 |
|
220 |
$schema->storage->txn_begin; |
221 |
|
222 |
my ($host_bibnum) = C4::Biblio::AddBiblio( host_record(), '' ); |
223 |
t::lib::Mocks::mock_preference( 'SearchEngine', 'Zebra' ); |
224 |
|
225 |
my $biblio = Koha::Biblios->find($host_bibnum); |
226 |
my $marc_record = $biblio->metadata->record; |
227 |
|
228 |
t::lib::Mocks::mock_preference( 'ShowComponentRecords', 'both' ); |
229 |
my $xml = C4::XSLT::XSLTParse4Display( |
230 |
{ |
231 |
biblionumber => $host_bibnum, |
232 |
record => $marc_record, |
233 |
xsl_syspref => 'OPACXSLTDetailsDisplay' |
234 |
} |
235 |
); |
236 |
unlike( $xml, qr{Show analytics}, 'If pref is on and record do not have component, show analytics link is not displayed' ); |
237 |
|
238 |
t::lib::Mocks::mock_preference( 'ShowComponentRecords', 'nowhere' ); |
239 |
$xml = C4::XSLT::XSLTParse4Display( |
240 |
{ |
241 |
biblionumber => $host_bibnum, |
242 |
record => $marc_record, |
243 |
xsl_syspref => 'OPACXSLTDetailsDisplay' |
244 |
} |
245 |
); |
246 |
like( $xml, qr{Show analytics}, 'If pref is off and record do not have component, show analytics link is displayed' ); |
247 |
|
248 |
|
249 |
my $search_mod = Test::MockModule->new('Koha::SearchEngine::Zebra::Search'); |
250 |
$search_mod->mock( 'simple_search_compat', \&search_component_record ); |
251 |
|
252 |
t::lib::Mocks::mock_preference( 'ShowComponentRecords', 'both' ); |
253 |
$xml = C4::XSLT::XSLTParse4Display( |
254 |
{ |
255 |
biblionumber => $host_bibnum, |
256 |
record => $marc_record, |
257 |
xsl_syspref => 'OPACXSLTDetailsDisplay' |
258 |
} |
259 |
); |
260 |
unlike( $xml, qr{Show analytics}, 'If pref is on and record has component, show analytics link is not displayed' ); |
261 |
|
262 |
t::lib::Mocks::mock_preference( 'ShowComponentRecords', 'nowhere' ); |
263 |
$xml = C4::XSLT::XSLTParse4Display( |
264 |
{ |
265 |
biblionumber => $host_bibnum, |
266 |
record => $marc_record, |
267 |
xsl_syspref => 'OPACXSLTDetailsDisplay' |
268 |
} |
269 |
); |
270 |
unlike( $xml, qr{Show analytics}, 'If pref is off and record has component, show analytics link is displayed' ); |
271 |
|
272 |
$search_mod->unmock('simple_search_compat'); |
273 |
|
274 |
$schema->storage->txn_rollback; |
275 |
}; |
276 |
|
277 |
sub host_record { |
278 |
my $marc = MARC::Record->new; |
279 |
$marc->append_fields( |
280 |
MARC::Field->new( '001', '1234' ), |
281 |
MARC::Field->new( '003', 'FIRST' ), |
282 |
MARC::Field->new( '245', '', '', a => 'Some title 1' ), |
283 |
); |
284 |
return $marc; |
285 |
} |
286 |
|
287 |
sub search_component_record { |
288 |
my $record = MARC::Record->new; |
289 |
$record->append_fields( |
290 |
MARC::Field->new( '001', '3456' ), |
291 |
MARC::Field->new( '245', '', '', a => 'Some title' ), |
292 |
MARC::Field->new( '773', '', '', w => '(FIRST)1234' ), |
293 |
); |
294 |
return ( undef, [$record], 1 ); |
295 |
} |