Lines 398-404
subtest 'update() tests' => sub {
Link Here
|
398 |
|
398 |
|
399 |
subtest 'delete() tests' => sub { |
399 |
subtest 'delete() tests' => sub { |
400 |
|
400 |
|
401 |
plan tests => 7; |
401 |
plan tests => 16; |
402 |
|
402 |
|
403 |
$schema->storage->txn_begin; |
403 |
$schema->storage->txn_begin; |
404 |
|
404 |
|
Lines 426-431
subtest 'delete() tests' => sub {
Link Here
|
426 |
# Unauthorized attempt to delete |
426 |
# Unauthorized attempt to delete |
427 |
$t->delete_ok( "//$unauth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id )->status_is(403); |
427 |
$t->delete_ok( "//$unauth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id )->status_is(403); |
428 |
|
428 |
|
|
|
429 |
my $subscription = |
430 |
$builder->build_object( { class => 'Koha::Subscriptions', value => { aqbooksellerid => $vendor->id } } ); |
431 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) |
432 |
->status_is( 409, 'REST3.2.4' ) |
433 |
->json_is( '/error' => 'Vendor cannot be deleted with existing baskets, subscriptions or invoices' ); |
434 |
$subscription->delete; |
435 |
my $basket = |
436 |
$builder->build_object( { class => 'Koha::Acquisition::Baskets', value => { booksellerid => $vendor->id } } ); |
437 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) |
438 |
->status_is( 409, 'REST3.2.4' ) |
439 |
->json_is( '/error' => 'Vendor cannot be deleted with existing baskets, subscriptions or invoices' ); |
440 |
$basket->delete; |
441 |
my $invoice = |
442 |
$builder->build_object( { class => 'Koha::Acquisition::Invoices', value => { booksellerid => $vendor->id } } ); |
443 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) |
444 |
->status_is( 409, 'REST3.2.4' ) |
445 |
->json_is( '/error' => 'Vendor cannot be deleted with existing baskets, subscriptions or invoices' ); |
446 |
$invoice->delete; |
447 |
|
429 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) |
448 |
$t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) |
430 |
->status_is( 204, 'REST3.2.4' )->content_is( '', 'REST3.3.4' ); |
449 |
->status_is( 204, 'REST3.2.4' )->content_is( '', 'REST3.3.4' ); |
431 |
|
450 |
|
432 |
- |
|
|