From d996e8266f66c9387bb340ba3c7e084ce20dc868 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 23 Nov 2022 09:30:33 +0100
Subject: [PATCH] Bug 31381: Add tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../api/v1/patrons_extended_attributes.t      | 26 ++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/api/v1/patrons_extended_attributes.t b/t/db_dependent/api/v1/patrons_extended_attributes.t
index 1766576fcb..278631fb33 100755
--- a/t/db_dependent/api/v1/patrons_extended_attributes.t
+++ b/t/db_dependent/api/v1/patrons_extended_attributes.t
@@ -34,7 +34,7 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
 
 subtest 'list_patron_attributes() tests' => sub {
 
-    plan tests => 9;
+    plan tests => 10;
 
     $schema->storage->txn_begin;
 
@@ -68,6 +68,30 @@ subtest 'list_patron_attributes() tests' => sub {
       ->status_is( 404 )
       ->json_is( '/error' => 'Patron not found' );
 
+    subtest 'nullable value' => sub {
+        # FIXME This is not correct, we should remove the NULLABLE clause at the DBMS level
+        # This test will need to be adjusted on bug 32331
+        plan tests => 3;
+
+        my $user = $builder->build_object({class => 'Koha::Patrons'});
+
+        $builder->build_object(
+            {
+                class => 'Koha::Patron::Attributes',
+                value => { borrowernumber => $user->id, attribute => undef }
+            }
+        );
+
+        $t->get_ok( "//$userid:$password@/api/v1/patrons/"
+              . $user->id
+              . '/extended_attributes' )->status_is( 200, 'SWAGGER3.2.2' )
+          ->json_is(
+            '' => $user->extended_attributes->to_api,
+            'Extended attributes retrieved correctly'
+          );
+
+    };
+
     $schema->storage->txn_rollback;
 };
 
-- 
2.30.2