3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Test::More tests => 1;
25 use t::lib::TestBuilder;
31 my $schema = Koha::Database->new->schema;
32 my $builder = t::lib::TestBuilder->new;
34 t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
36 my $t = Test::Mojo->new('Koha::REST::V1');
38 subtest 'delete() tests' => sub {
42 $schema->storage->txn_begin;
44 my $patron = $builder->build_object(
46 class => 'Koha::Patrons',
47 value => { flags => 9 }
50 my $password = 'thePassword123';
51 $patron->set_password( { password => $password, skip_validation => 1 } );
52 my $userid = $patron->userid;
54 my $item = $builder->build_sample_item();
55 my $biblio_id = $item->biblionumber;
57 # Bibs with items cannot be deleted
58 $t->delete_ok("//$userid:$password@/api/v1/biblios/$biblio_id")
63 # Bibs with no items can be deleted
64 $t->delete_ok("//$userid:$password@/api/v1/biblios/$biblio_id")
65 ->status_is(200)->content_is(q{""});
67 $t->delete_ok("//$userid:$password@/api/v1/biblios/$biblio_id")
70 $schema->storage->txn_rollback;