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

(-)a/t/db_dependent/XSLT.t (-6 / +49 lines)
Lines 20-29 use Modern::Perl; Link Here
20
use File::Temp;
20
use File::Temp;
21
use File::Path qw/make_path/;
21
use File::Path qw/make_path/;
22
use MARC::Record;
22
use MARC::Record;
23
use Test::More tests => 4;
23
use Test::More tests => 5;
24
use Test::Warn;
24
use Test::Warn;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use t::lib::Mocks qw( mock_preference );
27
27
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::Libraries;
29
use Koha::Libraries;
Lines 35-43 BEGIN { Link Here
35
35
36
my $schema  = Koha::Database->new->schema;
36
my $schema  = Koha::Database->new->schema;
37
my $builder = t::lib::TestBuilder->new;
37
my $builder = t::lib::TestBuilder->new;
38
our $cache = Koha::Caches->get_instance;
38
39
39
subtest 'Tests moved from t' => sub {
40
subtest 'Tests moved from t' => sub {
40
    plan tests => 8;
41
    plan tests => 11;
41
    $schema->storage->txn_begin;
42
    $schema->storage->txn_begin;
42
43
43
    my $dir = File::Temp->newdir();
44
    my $dir = File::Temp->newdir();
Lines 74-82 subtest 'Tests moved from t' => sub { Link Here
74
    is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
75
    is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
75
    is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
76
    is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
76
77
77
    my $matching_string = q{<syspref name="singleBranchMode">0</syspref>};
78
    my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>};
78
    my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
79
    my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
79
    ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0');
80
    ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value');
81
82
    t::lib::Mocks::mock_config('opachtdocs', "$dir");
83
    make_path("$dir/bootstrap/en/xslt/biblioexport");
84
85
    # Make XSL with title
86
    open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl";
87
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
88
    <xsl:stylesheet version="1.0"
89
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
90
       xmlns:marc="http://www.loc.gov/MARC21/slim"
91
       title="Export 01">
92
    </xsl:stylesheet>|;
93
    close $fh;
94
95
    # Make XSL without title
96
    open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl";
97
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
98
    <xsl:stylesheet version="1.0"
99
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
100
       xmlns:marc="http://www.loc.gov/MARC21/slim">
101
    </xsl:stylesheet>|;
102
    close $fh;
103
104
    open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl";
105
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|;
106
    close $fh;
107
108
    t::lib::Mocks::mock_preference( 'OpacExportOptions', 'custom');
109
    my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)};
110
    ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs");
111
    ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node");
112
    ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified");
80
113
81
    $schema->storage->txn_rollback;
114
    $schema->storage->txn_rollback;
82
};
115
};
Lines 201-206 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
201
    $schema->storage->txn_rollback;
234
    $schema->storage->txn_rollback;
202
};
235
};
203
236
237
subtest 'CustomXSLTExportList: Check export options' => sub {
238
    plan tests => 2;
239
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
240
    my $list = C4::XSLT::CustomXSLTExportList(1);
241
    is( $list>0, 1, 'We expect at least one result: simple export' );
242
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
243
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
244
    $list = C4::XSLT::CustomXSLTExportList(1);
245
    is( @$list, 0, 'We expect an empty list now' );
246
};
247
204
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
248
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
205
    plan tests => 23;
249
    plan tests => 23;
206
250
207
- 

Return to bug 17385