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

(-)a/t/XSLT.t (-4 / +35 lines)
Lines 21-33 use Test::More; Link Here
21
use File::Temp;
21
use File::Temp;
22
use File::Path qw/make_path/;
22
use File::Path qw/make_path/;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks qw( mock_preference );
25
25
26
use Module::Load::Conditional qw/check_install/;
26
use Module::Load::Conditional qw/check_install/;
27
27
28
BEGIN {
28
BEGIN {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
30
        plan tests => 9;
30
        plan tests => 12;
31
    } else {
31
    } else {
32
        plan skip_all => "Need Test::DBIx::Class"
32
        plan skip_all => "Need Test::DBIx::Class"
33
    }
33
    }
Lines 73-78 is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell ba Link Here
73
is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
73
is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
74
is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
74
is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
75
75
76
my $matching_string = q{<syspref name="singleBranchMode">0</syspref>};
76
my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>};
77
my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
77
my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
78
ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0');
78
ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value');
79
80
t::lib::Mocks::mock_config('opachtdocs', "$dir");
81
make_path("$dir/bootstrap/en/xslt/biblioexport");
82
83
# Make XSL with title
84
open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl";
85
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
86
<xsl:stylesheet version="1.0"
87
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
88
   xmlns:marc="http://www.loc.gov/MARC21/slim"
89
   title="Export 01">
90
</xsl:stylesheet>|;
91
close $fh;
92
93
# Make XSL without title
94
open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl";
95
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
96
<xsl:stylesheet version="1.0"
97
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
98
   xmlns:marc="http://www.loc.gov/MARC21/slim">
99
</xsl:stylesheet>|;
100
close $fh;
101
102
open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl";
103
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|;
104
close $fh;
105
106
my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)};
107
ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs");
108
ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node");
109
ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified");
(-)a/t/db_dependent/XSLT.t (-14 / +21 lines)
Lines 1-28 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
1
use Modern::Perl;
18
use Modern::Perl;
2
use Test::More tests => 2;
19
use Test::More tests => 3;
3
20
21
use Test::Warn;
22
use t::lib::TestBuilder;
4
use t::lib::Mocks;
23
use t::lib::Mocks;
5
use C4::XSLT;
24
use C4::XSLT;
6
use Koha::Caches;
25
use Koha::Caches;
7
use Koha::Database;
26
use Koha::Database;
8
27
9
our $schema = Koha::Database->new->schema;
28
our $schema = Koha::Database->new->schema;
29
my $builder = t::lib::TestBuilder->new;
10
our $cache = Koha::Caches->get_instance;
30
our $cache = Koha::Caches->get_instance;
11
31
12
# Here we go
32
# Here we go
13
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
14
subtest  'CustomXSLTExportList: Caching' => sub {
15
    plan tests => 1;
16
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
17
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
18
    my $list = C4::XSLT::CustomXSLTExportList(1);
19
    push @$list, { nonsense => 1 };
20
    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
21
    my $n = @$list;
22
    $list = C4::XSLT::CustomXSLTExportList(1);
23
    is( @$list, $n, 'This list comes from the cache and that is fine' );
24
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
25
};
26
subtest 'buildKohaItemsNamespace status tests' => sub {
34
subtest 'buildKohaItemsNamespace status tests' => sub {
27
    plan tests => 13;
35
    plan tests => 13;
28
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
36
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
29
- 

Return to bug 17385