|
Lines 17-24
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
|
|
20 |
use File::Temp; |
| 21 |
use File::Path qw/make_path/; |
| 20 |
use MARC::Record; |
22 |
use MARC::Record; |
| 21 |
use Test::More tests => 3; |
23 |
use Test::More tests => 4; |
| 22 |
use Test::Warn; |
24 |
use Test::Warn; |
| 23 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
| 24 |
use t::lib::Mocks; |
26 |
use t::lib::Mocks; |
|
Lines 34-43
BEGIN {
Link Here
|
| 34 |
my $schema = Koha::Database->new->schema; |
36 |
my $schema = Koha::Database->new->schema; |
| 35 |
my $builder = t::lib::TestBuilder->new; |
37 |
my $builder = t::lib::TestBuilder->new; |
| 36 |
|
38 |
|
| 37 |
$schema->storage->txn_begin; |
39 |
subtest 'Tests moved from t' => sub { |
|
|
40 |
plan tests => 8; |
| 41 |
$schema->storage->txn_begin; |
| 42 |
|
| 43 |
my $dir = File::Temp->newdir(); |
| 44 |
my @themes = ('prog', 'test'); |
| 45 |
my @langs = ('en', 'es-ES'); |
| 46 |
|
| 47 |
# create temporary files to be tested later |
| 48 |
foreach my $theme (@themes) { |
| 49 |
foreach my $lang (@langs) { |
| 50 |
make_path("$dir/$theme/$lang/xslt"); |
| 51 |
open my $fh, '>', "$dir/$theme/$lang/xslt/my_file.xslt"; |
| 52 |
print $fh "Theme $theme, language $lang"; |
| 53 |
close $fh; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
sub find_and_slurp { |
| 58 |
my ($dir, $theme, $lang) = @_; |
| 59 |
|
| 60 |
my $filename = C4::XSLT::_get_best_default_xslt_filename($dir, $theme, $lang, 'my_file.xslt'); |
| 61 |
open my $fh, '<', $filename; |
| 62 |
my $str = <$fh>; |
| 63 |
close $fh; |
| 64 |
return $str; |
| 65 |
} |
| 66 |
|
| 67 |
# These tests verify that we're finding the right XSLT file when present, |
| 68 |
# and falling back to the right XSLT file when an exact match is not present. |
| 69 |
is(find_and_slurp($dir, 'test', 'en' ), 'Theme test, language en', 'Found test/en'); |
| 70 |
is(find_and_slurp($dir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES'); |
| 71 |
is(find_and_slurp($dir, 'prog', 'en', ), 'Theme prog, language en', 'Found test/en'); |
| 72 |
is(find_and_slurp($dir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES'); |
| 73 |
is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell back to test/en for test/fr-FR'); |
| 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', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR'); |
| 76 |
|
| 77 |
my $matching_string = q{<syspref name="singleBranchMode">0</syspref>}; |
| 78 |
my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs(); |
| 79 |
ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); |
| 80 |
|
| 81 |
$schema->storage->txn_rollback; |
| 82 |
}; |
| 38 |
|
83 |
|
| 39 |
subtest 'buildKohaItemsNamespace status tests' => sub { |
84 |
subtest 'buildKohaItemsNamespace status tests' => sub { |
| 40 |
plan tests => 18; |
85 |
plan tests => 18; |
|
|
86 |
$schema->storage->txn_begin; |
| 41 |
|
87 |
|
| 42 |
t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2'); |
88 |
t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2'); |
| 43 |
t::lib::Mocks::mock_preference( 'OPACResultsLibrary', 'holdingbranch' ); |
89 |
t::lib::Mocks::mock_preference( 'OPACResultsLibrary', 'holdingbranch' ); |
|
Lines 152-163
subtest 'buildKohaItemsNamespace status tests' => sub {
Link Here
|
| 152 |
like($xml,qr{<substatus>Recall waiting</substatus>},"Waiting status takes precedence over In transit (recalls)"); |
198 |
like($xml,qr{<substatus>Recall waiting</substatus>},"Waiting status takes precedence over In transit (recalls)"); |
| 153 |
t::lib::Mocks::mock_preference('UseRecalls', 0); |
199 |
t::lib::Mocks::mock_preference('UseRecalls', 0); |
| 154 |
|
200 |
|
|
|
201 |
$schema->storage->txn_rollback; |
| 155 |
}; |
202 |
}; |
| 156 |
|
203 |
|
| 157 |
$schema->storage->txn_rollback; |
|
|
| 158 |
|
| 159 |
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { |
204 |
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { |
| 160 |
|
|
|
| 161 |
plan tests => 23; |
205 |
plan tests => 23; |
| 162 |
|
206 |
|
| 163 |
$schema->storage->txn_begin; |
207 |
$schema->storage->txn_begin; |
| 164 |
- |
|
|