# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $library->branchcode )
->status_is( 200, 'SWAGGER3.2.2' )
- ->json_is( '' => Koha::REST::V1::Library::_to_api( $library->TO_JSON ), 'SWAGGER3.3.2' );
+ ->json_is( '' => $library->to_api, 'SWAGGER3.3.2' );
my $non_existent_code = $library->branchcode;
$library->delete;
my $unauth_userid = $unauthorized_patron->userid;
my $library_obj = $builder->build_object({ class => 'Koha::Libraries' });
- my $library = Koha::REST::V1::Library::_to_api( $library_obj->TO_JSON );
+ my $library = $library_obj->to_api;
$library_obj->delete;
# Unauthorized attempt to write
$t->post_ok( "//$auth_userid:$password@/api/v1/libraries" => json => $library )
->status_is(409)
->json_has( '/error' => "Fails when trying to add an existing library_id")
- ->json_is( '/conflict', 'PRIMARY' ); } # WTF
- qr/^DBD::mysql::st execute failed: Duplicate entry '(.*)' for key 'PRIMARY'/;
+ ->json_like( '/conflict' => qr/(branches\.)?PRIMARY/ ); }
+ qr/^DBD::mysql::st execute failed: Duplicate entry '(.*)' for key '(branches\.)?PRIMARY'/;
$schema->storage->txn_rollback;
};
);
my $deleted_library = $builder->build_object( { class => 'Koha::Libraries' } );
- my $library_with_updated_field = Koha::REST::V1::Library::_to_api( $deleted_library->TO_JSON );
+ my $library_with_updated_field = $deleted_library->to_api;
$library_with_updated_field->{library_id} = $library_id;
$deleted_library->delete;