|
Lines 101-107
subtest 'list() tests' => sub {
Link Here
|
| 101 |
|
101 |
|
| 102 |
subtest 'get() tests' => sub { |
102 |
subtest 'get() tests' => sub { |
| 103 |
|
103 |
|
| 104 |
plan tests => 17; |
104 |
plan tests => 30; |
| 105 |
|
105 |
|
| 106 |
$schema->storage->txn_begin; |
106 |
$schema->storage->txn_begin; |
| 107 |
|
107 |
|
|
Lines 143-163
subtest 'get() tests' => sub {
Link Here
|
| 143 |
|
143 |
|
| 144 |
my $biblio = $builder->build_sample_biblio; |
144 |
my $biblio = $builder->build_sample_biblio; |
| 145 |
my $itype = |
145 |
my $itype = |
| 146 |
$builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; |
146 |
$builder->build_object( { class => 'Koha::ItemTypes' } ); |
| 147 |
$item = $builder->build_sample_item( |
147 |
$item = $builder->build_sample_item( |
| 148 |
{ biblionumber => $biblio->biblionumber, itype => $itype } ); |
148 |
{ biblionumber => $biblio->biblionumber, itype => $itype->itemtype } ); |
|
|
149 |
|
| 150 |
isnt( $biblio->itemtype, $itype->itemtype, "Test biblio level itemtype and item level itemtype do not match"); |
| 149 |
|
151 |
|
| 150 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
152 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
| 151 |
->status_is( 200, 'SWAGGER3.2.2' ) |
153 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 152 |
->json_is( '/item_type_id' => $itype, 'item-level_itypes:0' ) |
154 |
->json_is( '/item_type_id' => $itype->itemtype, 'item-level_itypes:0' ) |
| 153 |
->json_is( '/effective_item_type_id' => $biblio->itemtype, 'item-level_itypes:0' ); |
155 |
->json_is( '/effective_item_type_id' => $biblio->itemtype, 'item-level_itypes:0' ); |
| 154 |
|
156 |
|
| 155 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
157 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
| 156 |
|
158 |
|
| 157 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
159 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
| 158 |
->status_is( 200, 'SWAGGER3.2.2' ) |
160 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 159 |
->json_is( '/item_type_id' => $itype, 'item-level_itype:1' ) |
161 |
->json_is( '/item_type_id' => $itype->itemtype, 'item-level_itype:1' ) |
| 160 |
->json_is( '/effective_item_type_id' => $itype, 'item-level_itypes:1' ); |
162 |
->json_is( '/effective_item_type_id' => $itype->itemtype, 'item-level_itypes:1' ); |
|
|
163 |
|
| 164 |
|
| 165 |
my $biblio_itype = Koha::ItemTypes->find($biblio->itemtype); |
| 166 |
$biblio_itype->notforloan(3)->store(); |
| 167 |
$itype->notforloan(2)->store(); |
| 168 |
$item->notforloan(1)->store(); |
| 169 |
|
| 170 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
| 171 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 172 |
->json_is( '/not_for_loan_status' => 1, 'not_for_loan_status is 1' ) |
| 173 |
->json_is( '/effective_not_for_loan_status' => 1, 'effective_not_for_loan_status picks up item level' ); |
| 174 |
|
| 175 |
$item->notforloan(0)->store(); |
| 176 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
| 177 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 178 |
->json_is( '/not_for_loan_status' => 0, 'not_for_loan_status is 0' ) |
| 179 |
->json_is( '/effective_not_for_loan_status' => 2, 'effective_not_for_loan_status now picks up itemtype level - item-level_itypes:1' ); |
| 180 |
|
| 181 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); |
| 182 |
$t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) |
| 183 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 184 |
->json_is( '/not_for_loan_status' => 0, 'not_for_loan_status is 0' ) |
| 185 |
->json_is( '/effective_not_for_loan_status' => 3, 'effective_not_for_loan_status now picks up itemtype level - item-level_itypes:0' ); |
| 161 |
|
186 |
|
| 162 |
$schema->storage->txn_rollback; |
187 |
$schema->storage->txn_rollback; |
| 163 |
}; |
188 |
}; |
| 164 |
- |
|
|