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

(-)a/Koha/Schema/Result/Item.pm (-1 / +2 lines)
Lines 659-665 sub effective_itemtype { Link Here
659
    if ( $pref && $self->itype() ) {
659
    if ( $pref && $self->itype() ) {
660
        return $self->itype();
660
        return $self->itype();
661
    } else {
661
    } else {
662
        warn "item-level_itypes set but no itemtype set for item ($self->itemnumber)"
662
        my $itemnumber = $self->id;
663
        warn "item-level_itypes set but no itemtype set for item ($itemnumber)"
663
          if $pref;
664
          if $pref;
664
        return $self->biblioitemnumber()->itemtype();
665
        return $self->biblioitemnumber()->itemtype();
665
    }
666
    }
(-)a/t/db_dependent/Circulation/Returns.t (-4 / +10 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Test::More tests => 3;
20
use Test::More tests => 3;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
23
24
24
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 89-95 subtest "InProcessingToShelvingCart tests" => sub { Link Here
89
90
90
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
91
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
91
92
92
    plan tests => 2;
93
    plan tests => 4;
93
94
94
    # Set item-level item types
95
    # Set item-level item types
95
    C4::Context->set_preference( "item-level_itypes", 1 );
96
    C4::Context->set_preference( "item-level_itypes", 1 );
Lines 161-169 subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { Link Here
161
    is( $stat->itemtype, $ilevel_itemtype,
162
    is( $stat->itemtype, $ilevel_itemtype,
162
        "item-level itype recorded on statistics for return");
163
        "item-level itype recorded on statistics for return");
163
164
164
    AddIssue( $borrower, $item_without_itemtype->{ barcode } );
165
    my $itemnumber = $item_without_itemtype->{itemnumber};
165
    AddReturn( $item_without_itemtype->{ barcode }, $branch );
166
    warning_is { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) }
166
    # Test biblio-level itemtype was recorded on the 'statistics' table
167
      "item-level_itypes set but no itemtype set for item ($itemnumber)",
168
      '->effective_itemtype() raises a warning when falling back to bib-level';
169
    warning_is { AddReturn( $item_without_itemtype->{barcode}, $branch ) }
170
      "item-level_itypes set but no itemtype set for item ($itemnumber)",
171
      '->effective_itemtype() raises a warning when falling back to bib-level';
172
    # Test biblio-level itemtype was recorded on the 'statistics' table
167
    $stat = $schema->resultset('Statistic')->search({
173
    $stat = $schema->resultset('Statistic')->search({
168
        branch     => $branch,
174
        branch     => $branch,
169
        type       => 'return',
175
        type       => 'return',
(-)a/t/db_dependent/Items.t (-4 / +7 lines)
Lines 280-287 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
280
    $item->itype( undef );
280
    $item->itype( undef );
281
    $item->update();
281
    $item->update();
282
    my $effective_itemtype;
282
    my $effective_itemtype;
283
    my $itemnumber = $item->id;
283
    warning_is { $effective_itemtype = $item->effective_itemtype() }
284
    warning_is { $effective_itemtype = $item->effective_itemtype() }
284
                "item-level_itypes set but no itemtype set for item ($item->itemnumber)",
285
                "item-level_itypes set but no itemtype set for item ($itemnumber)",
285
                '->effective_itemtype() raises a warning when falling back to bib-level';
286
                '->effective_itemtype() raises a warning when falling back to bib-level';
286
287
287
    ok( defined $effective_itemtype &&
288
    ok( defined $effective_itemtype &&
Lines 292-298 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
292
};
293
};
293
294
294
subtest 'SearchItems test' => sub {
295
subtest 'SearchItems test' => sub {
295
    plan tests => 14;
296
    plan tests => 15;
296
297
297
    $schema->storage->txn_begin;
298
    $schema->storage->txn_begin;
298
    my $dbh = C4::Context->dbh;
299
    my $dbh = C4::Context->dbh;
Lines 445-451 subtest 'SearchItems test' => sub { Link Here
445
    ModItemFromMarc($item3_record, $biblionumber, $item3_itemnumber);
446
    ModItemFromMarc($item3_record, $biblionumber, $item3_itemnumber);
446
447
447
    # Make sure the link is used
448
    # Make sure the link is used
448
    my $item3 = GetItem($item3_itemnumber);
449
    my $item3;
450
    warning_is { $item3 = GetItem($item3_itemnumber) }
451
                "item-level_itypes set but no itemtype set for item ($item3_itemnumber)",
452
                '->effective_itemtype() raises a warning when falling back to bib-level';
449
    ok($item3->{itemnotes} eq 'foobar', 'itemnotes eq "foobar"');
453
    ok($item3->{itemnotes} eq 'foobar', 'itemnotes eq "foobar"');
450
454
451
    # Do the same search again.
455
    # Do the same search again.
452
- 

Return to bug 15599