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

(-)a/t/db_dependent/XSLT.t (-6 / +49 lines)
Lines 21-30 use File::Temp; Link Here
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::NoWarnings;
23
use Test::NoWarnings;
24
use Test::More tests => 5;
24
use Test::More tests => 6;
25
use Test::Warn;
25
use Test::Warn;
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
27
use t::lib::Mocks;
27
use t::lib::Mocks qw( mock_preference );
28
28
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::Libraries;
30
use Koha::Libraries;
Lines 36-44 BEGIN { Link Here
36
36
37
my $schema  = Koha::Database->new->schema;
37
my $schema  = Koha::Database->new->schema;
38
my $builder = t::lib::TestBuilder->new;
38
my $builder = t::lib::TestBuilder->new;
39
our $cache = Koha::Caches->get_instance;
39
40
40
subtest 'Tests moved from t' => sub {
41
subtest 'Tests moved from t' => sub {
41
    plan tests => 8;
42
    plan tests => 11;
42
    $schema->storage->txn_begin;
43
    $schema->storage->txn_begin;
43
44
44
    my $dir    = File::Temp->newdir();
45
    my $dir    = File::Temp->newdir();
Lines 78-86 subtest 'Tests moved from t' => sub { Link Here
78
    );
79
    );
79
    is( find_and_slurp( $dir, 'nope', 'fr-FR' ), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR' );
80
    is( find_and_slurp( $dir, 'nope', 'fr-FR' ), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR' );
80
81
81
    my $matching_string = q{<syspref name="singleBranchMode">0</syspref>};
82
    my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>};
82
    my $sysprefs_xml    = C4::XSLT::get_xslt_sysprefs();
83
    my $sysprefs_xml    = C4::XSLT::get_xslt_sysprefs();
83
    ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0' );
84
    ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value' );
85
86
    t::lib::Mocks::mock_config('opachtdocs', "$dir");
87
    make_path("$dir/bootstrap/en/xslt/biblioexport");
88
89
    # Make XSL with title
90
    open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl";
91
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
92
    <xsl:stylesheet version="1.0"
93
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
94
       xmlns:marc="http://www.loc.gov/MARC21/slim"
95
       title="Export 01">
96
    </xsl:stylesheet>|;
97
    close $fh;
98
99
    # Make XSL without title
100
    open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl";
101
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
102
    <xsl:stylesheet version="1.0"
103
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
104
       xmlns:marc="http://www.loc.gov/MARC21/slim">
105
    </xsl:stylesheet>|;
106
    close $fh;
107
108
    open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl";
109
    print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|;
110
    close $fh;
111
112
    t::lib::Mocks::mock_preference( 'OpacExportOptions', 'custom');
113
    my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)};
114
    ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs");
115
    ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node");
116
    ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified");
84
117
85
    $schema->storage->txn_rollback;
118
    $schema->storage->txn_rollback;
86
};
119
};
Lines 225-230 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
225
    $schema->storage->txn_rollback;
258
    $schema->storage->txn_rollback;
226
};
259
};
227
260
261
subtest 'CustomXSLTExportList: Check export options' => sub {
262
    plan tests => 2;
263
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
264
    my $list = C4::XSLT::CustomXSLTExportList(1);
265
    is( $list>0, 1, 'We expect at least one result: simple export' );
266
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
267
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
268
    $list = C4::XSLT::CustomXSLTExportList(1);
269
    is( @$list, 0, 'We expect an empty list now' );
270
};
271
228
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
272
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
229
    plan tests => 23;
273
    plan tests => 23;
230
274
231
- 

Return to bug 17385