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

(-)a/C4/XSLT.pm (+2 lines)
Lines 402-407 sub engine { Link Here
402
402
403
sub CustomXSLTExportList {
403
sub CustomXSLTExportList {
404
    my $opac = shift; # opac (1) vs intranet (0)
404
    my $opac = shift; # opac (1) vs intranet (0)
405
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
406
405
    my @tabFiles;
407
    my @tabFiles;
406
408
407
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
409
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
(-)a/t/db_dependent/XSLT.t (-104 / +13 lines)
Lines 1-113 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 1;
19
3
20
use Test::More tests => 2;
21
use Test::Warn;
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
4
use t::lib::Mocks;
5
use C4::XSLT;
6
use Koha::Database;
24
7
25
use Koha::ItemTypes;
8
our $schema = Koha::Database->new->schema;
26
27
BEGIN {
28
    use_ok('C4::XSLT');
29
}
30
31
my $schema  = Koha::Database->new->schema;
32
my $builder = t::lib::TestBuilder->new;
33
9
10
# Here we go
34
$schema->storage->txn_begin;
11
$schema->storage->txn_begin;
12
subtest 'CustomXSLTExportList: Check export options' => sub {
13
    plan tests => 2;
14
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
35
15
36
subtest 'buildKohaItemsNamespace status tests' => sub {
16
    my $list = C4::XSLT::CustomXSLTExportList(1);
37
    plan tests => 12;
17
    is( @$list>0, 1, 'We expect at least one result: simple export' );
38
    my $item  = $builder->build_sample_item({});
39
40
    my $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
41
    like($xml,qr{<status>available</status>},"Item is available when no other status applied");
42
43
    # notforloan
44
    {
45
46
        t::lib::Mocks::mock_preference('item-level_itypes', 0);
47
        $item->notforloan(0)->store;
48
        Koha::ItemTypes->find($item->itype)->notforloan(0)->store;
49
        Koha::ItemTypes->find($item->biblioitem->itemtype)->notforloan(1)->store;
50
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
51
        like($xml,qr{<status>reference</status>},"reference if positive itype notforloan value");
52
53
        t::lib::Mocks::mock_preference('item-level_itypes', 1);
54
        Koha::ItemTypes->find($item->itype)->notforloan(1)->store;
55
        Koha::ItemTypes->find($item->biblioitem->itemtype)->notforloan(0)->store;
56
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
57
        like($xml,qr{<status>reference</status>},"reference if positive itemtype notforloan value");
58
        Koha::ItemTypes->find($item->itype)->notforloan(0)->store;
59
60
        $item->notforloan(-1)->store;
61
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
62
        like($xml,qr{<status>On order</status>},"On order if negative notforloan value");
63
64
        $item->notforloan(1)->store;
65
        $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
66
        like($xml,qr{<status>reference</status>},"reference if positive notforloan value");
67
    }
68
69
    $item->onloan('2001-01-01')->store;
70
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
71
    like($xml,qr{<status>Checked out</status>},"Checked out status takes precedence over Not for loan");
72
73
    $item->withdrawn(1)->store;
74
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
75
    like($xml,qr{<status>Withdrawn</status>},"Withdrawn status takes precedence over Checked out");
76
77
    $item->itemlost(1)->store;
78
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
79
    like($xml,qr{<status>Lost</status>},"Lost status takes precedence over Withdrawn");
80
81
    $item->damaged(1)->store;
82
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
83
    like($xml,qr{<status>Damaged</status>},"Damaged status takes precedence over Lost");
84
85
    $builder->build({ source => "Branchtransfer", value => {
86
        itemnumber  => $item->itemnumber,
87
        datearrived => undef,
88
        }
89
    });
90
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
91
    like($xml,qr{<status>In transit</status>},"In-transit status takes precedence over Damaged");
92
93
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => {
94
        biblionumber => $item->biblionumber,
95
        itemnumber   => $item->itemnumber,
96
        found        => 'W',
97
        priority     => 0,
98
        }
99
    });
100
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
101
    like($xml,qr{<status>Waiting</status>},"Waiting status takes precedence over In transit");
102
103
    $builder->build({ source => "TmpHoldsqueue", value => {
104
        itemnumber => $item->itemnumber
105
        }
106
    });
107
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
108
    like($xml,qr{<status>Pending hold</status>},"Pending status takes precedence over all");
109
110
18
19
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
20
    $list = C4::XSLT::CustomXSLTExportList(1);
21
    is( @$list, 0, 'We expect an empty list now' );
111
};
22
};
112
113
$schema->storage->txn_rollback;
23
$schema->storage->txn_rollback;
114
- 

Return to bug 17385