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

(-)a/t/db_dependent/XSLT.t (-12 / +18 lines)
Lines 23-28 use Test::Warn; Link Here
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
25
26
use Koha::Database;
27
use Koha::Libraries;
26
use Koha::ItemTypes;
28
use Koha::ItemTypes;
27
29
28
BEGIN {
30
BEGIN {
Lines 46-58 subtest 'transformMARCXML4XSLT tests' => sub { Link Here
46
};
48
};
47
49
48
subtest 'buildKohaItemsNamespace status tests' => sub {
50
subtest 'buildKohaItemsNamespace status tests' => sub {
49
    plan tests => 14;
51
    plan tests => 16;
50
52
51
    t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2');
53
    t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2');
54
    t::lib::Mocks::mock_preference( 'OPACResultsLibrary', 'holdingbranch' );
55
    t::lib::Mocks::mock_preference( 'resultsMaxItems', '2' );
52
56
53
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
57
    my $itype = $builder->build_object({ class => 'Koha::ItemTypes' });
54
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
58
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
55
    my $item  = $builder->build_sample_item({ itype => $itype->itemtype });
59
    my $holdinglibrary = $builder->build_object({ class => 'Koha::Libraries' });
60
    my $item = $builder->build_sample_item({ itype => $itype->itemtype });
61
    $item->holdingbranch( $holdinglibrary->branchcode )->store;
56
    $item->biblioitem->itemtype($itemtype->itemtype)->store;
62
    $item->biblioitem->itemtype($itemtype->itemtype)->store;
57
63
58
    my $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
64
    my $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
Lines 93-111 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
93
99
94
    $item->onloan('2001-01-01')->store;
100
    $item->onloan('2001-01-01')->store;
95
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
101
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
96
    like($xml,qr{<status>Checked out</status>},"Checked out status takes precedence over Not for loan");
102
    like( $xml, qr/<status>other<\/status>/, "Checked out is part of other statuses" );
103
    like($xml,qr{<substatus>Checked out</substatus>},"Checked out status takes precedence over Not for loan");
97
104
98
    $item->withdrawn(1)->store;
105
    $item->withdrawn(1)->store;
99
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
106
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
100
    like($xml,qr{<status>Withdrawn</status>},"Withdrawn status takes precedence over Checked out");
107
    like($xml,qr{<substatus>Withdrawn</substatus>},"Withdrawn status takes precedence over Checked out");
101
108
102
    $item->itemlost(1)->store;
109
    $item->itemlost(1)->store;
103
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
110
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
104
    like($xml,qr{<status>Lost</status>},"Lost status takes precedence over Withdrawn");
111
    like($xml,qr{<substatus>Lost</substatus>},"Lost status takes precedence over Withdrawn");
105
112
106
    $item->damaged(1)->store;
113
    $item->damaged(1)->store;
107
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
114
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
108
    like($xml,qr{<status>Damaged</status>},"Damaged status takes precedence over Lost");
115
    like($xml,qr{<substatus>Damaged</substatus>},"Damaged status takes precedence over Lost");
109
116
110
    $builder->build({ source => "Branchtransfer", value => {
117
    $builder->build({ source => "Branchtransfer", value => {
111
        itemnumber  => $item->itemnumber,
118
        itemnumber  => $item->itemnumber,
Lines 114-120 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
114
        }
121
        }
115
    });
122
    });
116
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
123
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
117
    like($xml,qr{<status>In transit</status>},"In-transit status takes precedence over Damaged");
124
    like($xml,qr{<substatus>In transit</substatus>},"In-transit status takes precedence over Damaged");
118
125
119
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => {
126
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => {
120
        biblionumber => $item->biblionumber,
127
        biblionumber => $item->biblionumber,
Lines 124-139 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
124
        }
131
        }
125
    });
132
    });
126
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
133
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
127
    like($xml,qr{<status>Waiting</status>},"Waiting status takes precedence over In transit");
134
    like($xml,qr{<substatus>Waiting</substatus>},"Waiting status takes precedence over In transit");
128
135
129
    $builder->build({ source => "TmpHoldsqueue", value => {
136
    $builder->build({ source => "TmpHoldsqueue", value => {
130
        itemnumber => $item->itemnumber
137
        itemnumber => $item->itemnumber
131
        }
138
        }
132
    });
139
    });
133
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
140
    $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]);
134
    like($xml,qr{<status>Pending hold</status>},"Pending status takes precedence over all");
141
    like($xml,qr{<substatus>Pending hold</substatus>},"Pending status takes precedence over all");
135
142
    my $library_name = $holdinglibrary->branchname;
136
143
    like($xml,qr{<resultbranch>${library_name}</resultbranch>}, "Found resultbranch / holding branch" );
137
};
144
};
138
145
139
$schema->storage->txn_rollback;
146
$schema->storage->txn_rollback;
140
- 

Return to bug 26302