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

(-)a/t/db_dependent/Koha/AdditionalContents.t (-3 / +33 lines)
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 $page    = $builder->build_object(
339
        {
340
            class => 'Koha::AdditionalContents',
341
            value => { category => 'pages', branchcode => undef },
342
        }
343
    );
344
    $page->translated_contents(
345
        [
346
            { title => 'T', content => 'C1', lang => 'default' },
347
            { title => 'T', content => 'C2', lang => 'nl-NL' },
348
            { title => 'T', content => 'C3', lang => 'de' },
349
        ]
350
    );
351
    is( $page->translated_content('nl-NL')->content, 'C2', 'Found translation' );
352
    is( $page->translated_content('de')->content,    'C3', 'Found translation' );
353
354
    # Passing a sleep with language parameter (executed before 36875)
355
    my $hack = q|de') OR (SELECT 1 FROM (SELECT(SLEEP(10)))x)-- -|;
356
    my $time1 = time;
357
    is( $page->translated_content($hack)->content,   'C1', 'Hacking language param' );
358
    my $time2 = time;
359
    ok( $time2 < $time1 + 10, 'The sleep has not been executed' );
360
361
    $schema->storage->txn_rollback;
362
};
332
- 

Return to bug 36875