Bugzilla – Attachment 154382 Details for
Bug 17385
Add custom export formats for bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17385: Add tests for CustomXSLTExportList
Bug-17385-Add-tests-for-CustomXSLTExportList.patch (text/plain), 4.93 KB, created by
Hammat wele
on 2023-08-11 16:01:00 UTC
(
hide
)
Description:
Bug 17385: Add tests for CustomXSLTExportList
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2023-08-11 16:01:00 UTC
Size:
4.93 KB
patch
obsolete
>From eea307d03029537aeede9d7a7ef5becd304f8d1e Mon Sep 17 00:00:00 2001 >From: Alexis Ripetti <alexis.ripetti@inLibro.com> >Date: Tue, 3 Nov 2020 16:48:54 -0500 >Subject: [PATCH] Bug 17385: Add tests for CustomXSLTExportList > >Tests are now in one patch. >One test does not pass and I am not able to fix it. > >The test who fails : > ><pre> >$ prove -l t/db_dependent/XSLT.t >t/db_dependent/XSLT.t .. 1/3 > # 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. >t/db_dependent/XSLT.t .. Dubious, test returned 1 (wstat 256, 0x100) >Failed 1/3 subtests > >Test Summary Report >------------------- >t/db_dependent/XSLT.t (Wstat: 256 Tests: 3 Failed: 1) > Failed test: 2 > Non-zero exit status: 1 >Files=1, Tests=3, 3 wallclock secs ( 0.03 usr 0.00 sys + 1.74 cusr 0.14 csys = 1.91 CPU) >Result: FAIL ></pre> > >This one works fine : > ><pre> >$ prove -l t/XSLT.t >t/XSLT.t .. ok >All tests successful. >Files=1, Tests=12, 4 wallclock secs ( 0.02 usr 0.00 sys + 2.55 cusr 0.17 csys = 2.74 CPU) >Result: PASS ></pre> > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/XSLT.t | 54 +++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 49 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index 5f79b35b13..5ee1c8d333 100755 >--- a/t/db_dependent/XSLT.t >+++ b/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{<syspref name="singleBranchMode">0</syspref>}; >+ my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>}; > 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|<?xml version="1.0" encoding="UTF-8"?> >+ <xsl:stylesheet version="1.0" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:marc="http://www.loc.gov/MARC21/slim" >+ title="Export 01"> >+ </xsl:stylesheet>|; >+ close $fh; >+ >+ # Make XSL without title >+ open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl"; >+ print $fh qq|<?xml version="1.0" encoding="UTF-8"?> >+ <xsl:stylesheet version="1.0" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:marc="http://www.loc.gov/MARC21/slim"> >+ </xsl:stylesheet>|; >+ close $fh; >+ >+ open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl"; >+ print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|; >+ 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; > >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17385
:
55961
|
58308
|
64033
|
64034
|
67357
|
67579
|
74660
|
74661
|
79055
|
79056
|
80675
|
81385
|
81386
|
84388
|
84389
|
84390
|
86875
|
86876
|
86877
|
86878
|
86879
|
86880
|
97076
|
97101
|
97102
|
97103
|
97104
|
97105
|
100289
|
100290
|
100291
|
100292
|
100293
|
100663
|
100670
|
100671
|
100672
|
100673
|
100674
|
100675
|
112671
|
112672
|
112673
|
112674
|
112675
|
112676
|
112677
|
112678
|
112679
|
112680
|
112681
|
112682
|
112956
|
112957
|
112958
|
112959
|
130283
|
130284
|
130285
|
130286
|
130287
|
130691
|
130692
|
130693
|
130694
|
130695
|
131492
|
132488
|
132489
|
132490
|
132491
|
132492
|
132493
|
132581
|
133498
|
133499
|
133500
|
133501
|
133502
|
133503
|
133504
|
138031
|
138032
|
138033
|
138034
|
138035
|
138036
|
138037
|
138082
|
138083
|
138084
|
138085
|
138086
|
138087
|
138088
|
138132
|
139277
|
139278
|
139279
|
139280
|
139281
|
139282
|
139283
|
139284
|
141157
|
141158
|
141159
|
141160
|
141161
|
141162
|
141163
|
141164
|
144335
|
144336
|
144380
|
144384
|
151095
|
151096
|
151097
|
151098
|
151099
|
151102
|
151103
|
151104
|
151105
|
151106
|
151377
|
151378
|
151379
|
151380
|
151381
|
154379
|
154380
|
154381
|
154382
|
154383
|
156815
|
156816
|
156817
|
156818
|
156819
|
159142
|
159143
|
159144
|
159145
|
159146
|
159147
|
159148
|
163623
|
170014
|
170015
|
170016
|
170017
|
170018
|
170019
|
170026
|
170027
|
170028
|
170029
|
170030
|
170031
|
170983
|
170984
|
170985
|
170986
|
170987
|
170988