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

(-)a/t/db_dependent/Items.t (-2 / +15 lines)
Lines 24-29 use C4::Branch; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
25
26
use Test::More tests => 8;
26
use Test::More tests => 8;
27
use Test::Warn;
27
28
28
BEGIN {
29
BEGIN {
29
    use_ok('C4::Items');
30
    use_ok('C4::Items');
Lines 195-201 subtest 'GetItemsInfo tests' => sub { Link Here
195
196
196
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
197
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
197
198
198
    plan tests => 2;
199
    plan tests => 4;
199
200
200
    # Start transaction
201
    # Start transaction
201
    $dbh->{AutoCommit} = 0;
202
    $dbh->{AutoCommit} = 0;
Lines 225-230 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
225
    C4::Context->set_preference( 'item-level_itypes', 1 );
226
    C4::Context->set_preference( 'item-level_itypes', 1 );
226
    ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is enabled' );
227
    ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is enabled' );
227
228
229
    # If itemtype is not defined and item-level_level item types are set
230
    # fallback to biblio-level itemtype (Bug 14651) and warn
231
    $item->itype( undef );
232
    $item->update();
233
    my $effective_itemtype;
234
    warning_is { $effective_itemtype = $item->effective_itemtype() }
235
                "item-level_itypes set but no itemtype set for item ($item->itemnumber)",
236
                '->effective_itemtype() raises a warning when falling back to bib-level';
237
238
    ok( defined $effective_itemtype &&
239
                $effective_itemtype eq 'BIB_LEVEL',
240
        '$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' );
241
228
    $dbh->rollback;
242
    $dbh->rollback;
229
};
243
};
230
244
231
- 

Return to bug 14651