Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::AdditionalContents; |
25 |
use Koha::AdditionalContents; |
Lines 328-331
subtest 'find_best_match' => sub {
Link Here
|
328 |
# Note: find_best_match is tested further via $libary->opac_info; see t/db_dependent/Koha/Library.t |
328 |
# Note: find_best_match is tested further via $libary->opac_info; see t/db_dependent/Koha/Library.t |
329 |
|
329 |
|
330 |
$schema->storage->txn_rollback; |
330 |
$schema->storage->txn_rollback; |
331 |
} |
331 |
}; |
|
|
332 |
|
333 |
subtest '->translated_content' => sub { |
334 |
plan tests => 4; |
335 |
|
336 |
$schema->storage->txn_begin; |
337 |
|
338 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
339 |
my $page = $builder->build_object( |
340 |
{ |
341 |
class => 'Koha::AdditionalContents', |
342 |
value => { category => 'pages', branchcode => undef }, |
343 |
} |
344 |
); |
345 |
$page->translated_contents( |
346 |
[ |
347 |
{ title => 'T', content => 'C1', lang => 'default' }, |
348 |
{ title => 'T', content => 'C2', lang => 'nl-NL' }, |
349 |
{ title => 'T', content => 'C3', lang => 'de' }, |
350 |
] |
351 |
); |
352 |
is( $page->translated_content('nl-NL')->content, 'C2', 'Found translation' ); |
353 |
is( $page->translated_content('de')->content, 'C3', 'Found translation' ); |
354 |
|
355 |
# Hacking a sleep into the ORDER BY clause |
356 |
my $hack = q|de') OR (SELECT 1 FROM (SELECT(SLEEP(10)))x)-- -|; |
357 |
my $time1 = time; |
358 |
is( $page->translated_content($hack)->content, 'C1', 'Hacking language param' ); |
359 |
my $time2 = time; |
360 |
ok( $time2 < $time1 + 10, 'The sleep has not been executed' ); |
361 |
|
362 |
$schema->storage->txn_rollback; |
363 |
}; |
332 |
- |
|
|