Lines 1-28
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
use Test::More tests => 2; |
2 |
use Test::More tests => 4; |
3 |
|
3 |
|
4 |
use t::lib::Mocks; |
4 |
use t::lib::Mocks; |
5 |
use C4::XSLT; |
5 |
use C4::XSLT; |
6 |
use Koha::Caches; |
|
|
7 |
use Koha::Database; |
6 |
use Koha::Database; |
|
|
7 |
use Test::Warn; |
8 |
use t::lib::TestBuilder; |
9 |
use Koha::ItemTypes; |
10 |
use Koha::Caches; |
8 |
|
11 |
|
9 |
our $schema = Koha::Database->new->schema; |
12 |
our $schema = Koha::Database->new->schema; |
10 |
our $cache = Koha::Caches->get_instance; |
13 |
our $cache = Koha::Caches->get_instance; |
11 |
|
14 |
|
|
|
15 |
BEGIN { |
16 |
use_ok('C4::XSLT'); |
17 |
} |
18 |
my $builder = t::lib::TestBuilder->new; |
12 |
# Here we go |
19 |
# Here we go |
13 |
$schema->storage->txn_begin; |
20 |
$schema->storage->txn_begin; |
14 |
subtest 'CustomXSLTExportList: Caching' => sub { |
|
|
15 |
plan tests => 1; |
16 |
t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); |
17 |
$cache->clear_from_cache('CustomXSLTExportListOPAC'); |
18 |
my $list = C4::XSLT::CustomXSLTExportList(1); |
19 |
push @$list, { nonsense => 1 }; |
20 |
$cache->set_in_cache( 'CustomXSLTExportListOPAC', $list ); |
21 |
my $n = @$list; |
22 |
$list = C4::XSLT::CustomXSLTExportList(1); |
23 |
is( @$list, $n, 'This list comes from the cache and that is fine' ); |
24 |
$cache->clear_from_cache('CustomXSLTExportListOPAC'); |
25 |
}; |
26 |
subtest 'buildKohaItemsNamespace status tests' => sub { |
21 |
subtest 'buildKohaItemsNamespace status tests' => sub { |
27 |
plan tests => 13; |
22 |
plan tests => 13; |
28 |
my $item = $builder->build_sample_item({}); |
23 |
my $item = $builder->build_sample_item({}); |
Lines 99-102
subtest 'buildKohaItemsNamespace status tests' => sub {
Link Here
|
99 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
94 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
100 |
like($xml,qr{<status>Pending hold</status>},"Pending status takes precedence over all"); |
95 |
like($xml,qr{<status>Pending hold</status>},"Pending status takes precedence over all"); |
101 |
}; |
96 |
}; |
|
|
97 |
subtest 'CustomXSLTExportList: Caching' => sub { |
98 |
plan tests => 1; |
99 |
t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); |
100 |
$cache->clear_from_cache('CustomXSLTExportListOPAC'); |
101 |
my $list = C4::XSLT::CustomXSLTExportList(1); |
102 |
push @$list, { nonsense => 1 }; |
103 |
$cache->set_in_cache('CustomXSLTExportListOPAC', $list ); |
104 |
my $n = @$list; |
105 |
$list = C4::XSLT::CustomXSLTExportList(1); |
106 |
is( @$list, $n, 'This list comes from the cache and that is fine' ); |
107 |
$cache->clear_from_cache('CustomXSLTExportListOPAC'); |
108 |
}; |
109 |
subtest 'CustomXSLTExportList: Check export options' => sub { |
110 |
plan tests => 2; |
111 |
t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); |
112 |
my $list = C4::XSLT::CustomXSLTExportList(1); |
113 |
is( $list>0, 1, 'We expect at least one result: simple export' ); |
114 |
$cache->clear_from_cache('CustomXSLTExportListOPAC'); |
115 |
t::lib::Mocks::mock_preference('OpacExportOptions', 'dc'); |
116 |
$list = C4::XSLT::CustomXSLTExportList(1); |
117 |
is( @$list, 0, 'We expect an empty list now' ); |
118 |
}; |
102 |
$schema->storage->txn_rollback; |
119 |
$schema->storage->txn_rollback; |
103 |
- |
|
|