|
Line 0
Link Here
|
| 0 |
- |
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; |
| 19 |
|
| 20 |
use Test::More tests => 2; |
| 21 |
use Test::Warn; |
| 22 |
use t::lib::TestBuilder; |
| 23 |
|
| 24 |
|
| 25 |
BEGIN { |
| 26 |
use_ok('C4::XSLT'); |
| 27 |
} |
| 28 |
|
| 29 |
my $schema = Koha::Database->new->schema; |
| 30 |
my $builder = t::lib::TestBuilder->new; |
| 31 |
|
| 32 |
$schema->storage->txn_begin; |
| 33 |
|
| 34 |
subtest 'buildKohaItemsNamespace status tests' => sub { |
| 35 |
plan tests => 10; |
| 36 |
my $item = $builder->build_sample_item({ |
| 37 |
}); |
| 38 |
|
| 39 |
my $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 40 |
like($xml,qr/<status>available<\/status>/,"Item is available when no other status applied"); |
| 41 |
|
| 42 |
$item->notforloan(-1)->store; |
| 43 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 44 |
like($xml,qr/<status>On order<\/status>/,"On order if negative notforloan value"); |
| 45 |
|
| 46 |
$item->notforloan(1)->store; |
| 47 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 48 |
like($xml,qr/<status>reference<\/status>/,"reference if positive notforloan value"); |
| 49 |
|
| 50 |
$item->onloan('2001-01-01')->store; |
| 51 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 52 |
like($xml,qr/<status>Checked out<\/status>/,"Checked out status takes precedence over Not for loan"); |
| 53 |
|
| 54 |
$item->withdrawn(1)->store; |
| 55 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 56 |
like($xml,qr/<status>Withdrawn<\/status>/,"Withdrawn status takes precedence over Checked out"); |
| 57 |
|
| 58 |
$item->itemlost(1)->store; |
| 59 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 60 |
like($xml,qr/<status>Lost<\/status>/,"Lost status takes precedence over Withdrawn"); |
| 61 |
|
| 62 |
$item->damaged(1)->store; |
| 63 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 64 |
like($xml,qr/<status>Damaged<\/status>/,"Damaged status takes precedence over Lost"); |
| 65 |
|
| 66 |
$builder->build({ source => "Branchtransfer", value => { |
| 67 |
itemnumber => $item->itemnumber, |
| 68 |
datearrived => undef, |
| 69 |
} |
| 70 |
}); |
| 71 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 72 |
like($xml,qr/<status>In transit<\/status>/,"In-transit status takes precedence over Damaged"); |
| 73 |
|
| 74 |
my $hold = $builder->build_object({ class => 'Koha::Holds', value => { |
| 75 |
biblionumber => $item->biblionumber, |
| 76 |
itemnumber => $item->itemnumber, |
| 77 |
found => 'W', |
| 78 |
priority => 0, |
| 79 |
} |
| 80 |
}); |
| 81 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 82 |
like($xml,qr/<status>Waiting<\/status>/,"Waiting status takes precedence over In transit"); |
| 83 |
|
| 84 |
$builder->build({ source => "TmpHoldsqueue", value => { |
| 85 |
itemnumber => $item->itemnumber |
| 86 |
} |
| 87 |
}); |
| 88 |
$xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); |
| 89 |
like($xml,qr/<status>Pending hold<\/status>/,"Pending status takes precedence over all"); |
| 90 |
|
| 91 |
|
| 92 |
}; |
| 93 |
|
| 94 |
$schema->storage->txn_rollback; |