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

(-)a/t/db_dependent/Items.t (-2 / +45 lines)
Lines 27-37 use Koha::Library; Link Here
27
use Koha::DateUtils;
27
use Koha::DateUtils;
28
use Koha::MarcSubfieldStructures;
28
use Koha::MarcSubfieldStructures;
29
use Koha::Caches;
29
use Koha::Caches;
30
use C4::Items;
30
31
31
use t::lib::Mocks;
32
use t::lib::Mocks;
32
use t::lib::TestBuilder;
33
use t::lib::TestBuilder;
33
34
34
use Test::More tests => 14;
35
use Test::More tests => 15;
35
36
36
use Test::Warn;
37
use Test::Warn;
37
38
Lines 837-842 subtest 'Test logging for ModItem' => sub { Link Here
837
    $schema->storage->txn_rollback;
838
    $schema->storage->txn_rollback;
838
};
839
};
839
840
841
subtest 'tests for GetMarcItem' => sub {
842
843
    plan tests => 1;
844
    $schema->storage->txn_begin;
845
    my $builder  = t::lib::TestBuilder->new;
846
    my $library  = $builder->build({ source => 'Branch', });
847
    my $itemtype = $builder->build({ source => 'Itemtype', });
848
    my $biblio   = $builder->build({
849
        source => 'Biblio',
850
        value=>{
851
            frameworkcode => "",
852
        }
853
    });
854
    my $biblioitem = $builder->build({
855
        source => 'Biblioitem',
856
        value => { biblionumber => $biblio->{biblionumber} },
857
    });
858
    my $item1 = $builder->build_object({
859
        class => 'Koha::Items',
860
        value => {
861
            biblionumber     => $biblio->{biblionumber},
862
            biblioitemnumber => $biblioitem->{biblioitemnumber},
863
            itype            => $itemtype->{itype},
864
            homebranch       => $library->{branchcode},
865
            barcode          => undef,
866
            restricted       => 1,
867
            itemcallnumber   => "",
868
            cn_sort          => "",
869
        }
870
    });
871
    my ($itemtag, $item_num_subfield )=C4::Biblio::GetMarcFromKohaField("items.itemnumber","");
872
    my $get_itemnumber = $item1->itemnumber;
873
    my $item1_marc = C4::Items::GetMarcItem( $biblio->{biblionumber}, $item1->itemnumber );
874
    my (undef, undef, $itemnumber2 ) = AddItemFromMarc( $item1_marc, $biblio->{biblionumber} );
875
    my $item2_marc = C4::Items::GetMarcItem( $biblio->{biblionumber}, $itemnumber2 );
876
    my ($itemtag, $item_num_subfield )=C4::Biblio::GetMarcFromKohaField("items.itemnumber",""); #get itemnumber tag
877
    $item1_marc->field($itemtag)->delete_subfield(code => $item_num_subfield); #and remove it
878
    $item2_marc->field($itemtag)->delete_subfield(code => $item_num_subfield); #because it won't match
879
    is_deeply( $item1_marc, $item2_marc, "The Marc should match if the items are the same");
880
    $schema->storage->txn_rollback;
881
882
};
883
840
# Helper method to set up a Biblio.
884
# Helper method to set up a Biblio.
841
sub get_biblio {
885
sub get_biblio {
842
    my ( $frameworkcode ) = @_;
886
    my ( $frameworkcode ) = @_;
843
- 

Return to bug 21006