From 935e5a49207a039b8ead2d9b4ab8b01dfcbe783c Mon Sep 17 00:00:00 2001
From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
Date: Mon, 10 Feb 2020 15:36:25 +0000
Subject: [PATCH] Bug 24609: Add API unit tests

Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 t/db_dependent/api/v1/checkouts.t | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t
index 404b2a7190..eee996794f 100755
--- a/t/db_dependent/api/v1/checkouts.t
+++ b/t/db_dependent/api/v1/checkouts.t
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 93;
+use Test::More tests => 98;
 use Test::MockModule;
 use Test::Mojo;
 use t::lib::Mocks;
@@ -224,3 +224,15 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id . "/all
         current_renewals => 1,
         error            => 'too_many'
     });
+
+my $new_date_due = Koha::DateUtils::dt_from_string( $issue2->date_due );
+$new_date_due->add(days => 2);
+$new_date_due = output_pref({ dateformat => "rfc3339", dt => $new_date_due });
+$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id  => json => { due_date => $new_date_due })
+    ->status_is(200, 'Due date updated successfully')
+    ->json_is('/due_date' => $new_date_due);
+
+$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id  => json => { item_id => 3 })
+    ->status_is(400, 'readOnly properties not updateable');
+
+$schema->storage->txn_rollback;
-- 
2.32.0