@@ -, +, @@ # Failed test 'This list comes from the cache and that is fine' # at t/db_dependent/XSLT.t line 122. # got: '1' # expected: '2' # Looks like you failed 1 test of 1. # Failed test 'CustomXSLTExportList: Caching' # at t/db_dependent/XSLT.t line 124. # Looks like you failed 1 test of 3. ------------------- Failed test: 2 Non-zero exit status: 1 --- t/db_dependent/XSLT.t | 54 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) --- a/t/db_dependent/XSLT.t +++ a/t/db_dependent/XSLT.t @@ -20,10 +20,10 @@ use Modern::Perl; use File::Temp; use File::Path qw/make_path/; use MARC::Record; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Warn; use t::lib::TestBuilder; -use t::lib::Mocks; +use t::lib::Mocks qw( mock_preference ); use Koha::Database; use Koha::Libraries; @@ -35,9 +35,10 @@ BEGIN { my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; +our $cache = Koha::Caches->get_instance; subtest 'Tests moved from t' => sub { - plan tests => 8; + plan tests => 11; $schema->storage->txn_begin; my $dir = File::Temp->newdir(); @@ -74,9 +75,41 @@ subtest 'Tests moved from t' => sub { is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES'); is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR'); - my $matching_string = q{0}; + my $matching_string = q{[0|1]}; my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs(); - ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); + ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value'); + + t::lib::Mocks::mock_config('opachtdocs', "$dir"); + make_path("$dir/bootstrap/en/xslt/biblioexport"); + + # Make XSL with title + open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl"; + print $fh qq| + + |; + close $fh; + + # Make XSL without title + open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl"; + print $fh qq| + + |; + close $fh; + + open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl"; + print $fh qq||; + close $fh; + + t::lib::Mocks::mock_preference( 'OpacExportOptions', 'custom'); + my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)}; + ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs"); + ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node"); + ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified"); $schema->storage->txn_rollback; }; @@ -201,6 +234,17 @@ subtest 'buildKohaItemsNamespace status tests' => sub { $schema->storage->txn_rollback; }; +subtest 'CustomXSLTExportList: Check export options' => sub { + plan tests => 2; + t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); + my $list = C4::XSLT::CustomXSLTExportList(1); + is( $list>0, 1, 'We expect at least one result: simple export' ); + $cache->clear_from_cache('CustomXSLTExportListOPAC'); + t::lib::Mocks::mock_preference('OpacExportOptions', 'dc'); + $list = C4::XSLT::CustomXSLTExportList(1); + is( @$list, 0, 'We expect an empty list now' ); +}; + subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { plan tests => 23; --