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

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

Return to bug 20664