Bug 24545: Fix license statements
[srvgit] / t / db_dependent / api / v1 / libraries.t
index 5ac8ecc..631cd35 100644 (file)
@@ -2,18 +2,18 @@
 
 # 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;
 
@@ -121,7 +121,7 @@ subtest 'get() tests' => sub {
 
     $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;
@@ -155,7 +155,7 @@ subtest 'add() tests' => sub {
     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
@@ -199,8 +199,8 @@ subtest 'add() tests' => sub {
         $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;
 };
@@ -245,7 +245,7 @@ subtest 'update() tests' => sub {
       );
 
     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;