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

(-)a/t/db_dependent/api/v1/items.t (-2 / +61 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 5;
22
use Test::More tests => 6;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Mojo;
24
use Test::Mojo;
25
use Test::Warn;
25
use Test::Warn;
Lines 31-36 use Mojo::JSON qw(encode_json); Link Here
31
31
32
use C4::Auth;
32
use C4::Auth;
33
use Koha::Items;
33
use Koha::Items;
34
use Koha::Item;
34
use Koha::Database;
35
use Koha::Database;
35
36
36
my $schema  = Koha::Database->new->schema;
37
my $schema  = Koha::Database->new->schema;
Lines 40-45 t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); Link Here
40
41
41
my $t = Test::Mojo->new('Koha::REST::V1');
42
my $t = Test::Mojo->new('Koha::REST::V1');
42
43
44
subtest 'to_api_mapping() tests' => sub {
45
46
    plan tests => 46;
47
48
    $schema->storage->txn_begin;
49
50
    my $mapping = Koha::Item->to_api_mapping;
51
    is($mapping->{itemnumber}, 'item_id', 'items.itemnumber is mapped as item_id in to_api_mapping');
52
    is($mapping->{biblionumber}, 'biblio_id', 'items.biblionumber is mapped as biblio_id in to_api_mapping');
53
    is($mapping->{biblioitemnumber}, undef, 'items.biblionumber is mapped as undef in to_api_mapping');
54
    is($mapping->{barcode}, 'external_id', 'items.barcode is mapped as external_id in to_api_mapping');
55
    is($mapping->{dateaccessioned}, 'acquisition_date', 'items.dateaccessioned is mapped as acquisition_date in to_api_mapping');
56
    is($mapping->{booksellerid}, 'acquisition_source', 'items.booksellerid is mapped as acquisition_source in to_api_mapping');
57
    is($mapping->{homebranch}, 'home_library_id', 'items.homebranch is mapped as home_libray_id in to_api_mapping');
58
    is($mapping->{price}, 'purchase_price', 'items.price is mapped as purchase_price in to_api_mapping');
59
    is($mapping->{replacementprice}, 'replacement_price', 'items.replacementprice is mapped as replacement_price in to_api_mapping');
60
    is($mapping->{replacementpricedate}, 'replacement_price_date', 'items.replacementpricedate is mapped as replacement_price_date in to_api_mapping');
61
    is($mapping->{datelastborrowed}, 'last_checkout_date', 'items.datelastborrowered is mapped as last_checkout_date in to_api_mapping');
62
    is($mapping->{datelastseen}, 'last_seen_date', 'items.datelastseen is mapped as last_seen_date in to_api_mapping');
63
    is($mapping->{stack}, 'stack', 'items.stack is mapped as stack in to_api_mapping');
64
    is($mapping->{notforloan}, 'not_for_loan_status', 'items.notforloan is mapped as not_for_loan_status in to_api_mapping');
65
    is($mapping->{damaged}, 'damaged_status', 'items.damaged is mapped as damaged_status in to_api_mapping');
66
    is($mapping->{damaged_on}, 'damaged_date', 'items.damaged_on is mapped as damaged_date in to_api_mapping');
67
    is($mapping->{itemlost}, 'lost_status', 'items.itemlost is mapped as lost_status in to_api_mapping');
68
    is($mapping->{itemlost_on}, 'lost_date', 'items.itemlost_on is mapped as lost_date in to_api_mapping');
69
    is($mapping->{withdrawn}, 'withdrawn', 'items.withdrawn is mapped as withdrawn in to_api_mapping');
70
    is($mapping->{withdrawn_on}, 'withdrawn_date', 'items.withdrawn_date is mapped as withdrawn in to_api_mapping');
71
    is($mapping->{itemcallnumber}, 'callnumber', 'items.itemcallnumber is mapped as callnumber in to_api_mapping');
72
    is($mapping->{coded_location_qualifier}, 'coded_location_qualifier', 'items.coded_location_qualifier is mapped as coded_location_qualifier in to_api_mapping');
73
    is($mapping->{issues}, 'checkouts_count', 'items.issues is mapped as checkouts_count in to_api_mapping');
74
    is($mapping->{renewals}, 'renewals_count', 'items.renewals is mapped as renewals_count in to_api_mapping');
75
    is($mapping->{reserves}, 'holds_count', 'items.reserves is mapped as holds_count in to_api_mapping');
76
    is($mapping->{restricted}, 'restricted_status', 'items.restricted is mapped as restricted_status in to_api_mapping');
77
    is($mapping->{itemnotes}, 'public_notes', 'items.itemnotes is mapped as public_notes in to_api_mapping');
78
    is($mapping->{itemnotes_nonpublic}, 'internal_notes', 'items.itemnotes_nonpublic is mapped as internal_notes in to_api_mapping');
79
    is($mapping->{holdingbranch}, 'holding_library_id', 'items.holdingbranch is mapped as holding_library_id in to_api_mapping');
80
    is($mapping->{timestamp}, 'timestamp', 'items.timestamp is mapped as timestamp in to_api_mapping');
81
    is($mapping->{location}, 'location', 'items.location is mapped as location in to_api_mapping');
82
    is($mapping->{permanent_location}, 'permanent_location', 'items.permanent_location is mapped as permanent_location in to_api_mapping');
83
    is($mapping->{onloan}, 'checked_out_date', 'items.onloan is mapped as checked_out_date in to_api_mapping');
84
    is($mapping->{cn_source}, 'call_number_source', 'items.cnsource is mapped as call_number_source in to_api_mapping');
85
    is($mapping->{cn_sort}, 'call_number_sort', 'items.cnsort is mapped as call_number_sort in to_api_mapping');
86
    is($mapping->{ccode}, 'collection_code', 'items.ccode is mapped as collection_code in to_api_mapping');
87
    is($mapping->{materials}, 'materials_notes', 'items.materials is mapped as materials_notes in to_api_mapping');
88
    is($mapping->{uri}, 'uri', 'items.uri is mapped as uri in to_api_mapping');
89
    is($mapping->{itype}, 'item_type_id', 'items.itype is mapped as item_type_id in to_api_mapping');
90
    is($mapping->{more_subfields_xml}, 'extended_subfields', 'items.more_subfields_xml is mapped as extended_subfields in to_api_mapping');
91
    is($mapping->{enumchron}, 'serial_issue_number', 'items.enumchron is mapped as serial_issue_number in to_api_mapping');
92
    is($mapping->{copynumber}, 'copy_number', 'items.copynumber is mapped as copy_number in to_api_mapping');
93
    is($mapping->{stocknumber}, 'inventory_number', 'items.stocknumber is mapped as inventory_number in to_api_mapping');
94
    is($mapping->{new_status}, 'new_status', 'items.new_status is mapped as new_status in to_api_mapping');
95
    is($mapping->{deleted_on}, undef, 'items.deleted_on is mapped as undef in to_api_mapping');
96
97
    is( scalar keys %{$mapping}, 45, 'Correct number of columns in mapping' );
98
99
100
    $schema->storage->txn_rollback;
101
};
102
43
subtest 'list() tests' => sub {
103
subtest 'list() tests' => sub {
44
104
45
    plan tests => 15;
105
    plan tests => 15;
46
- 

Return to bug 37639