Bug 31381: Add tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 23 Nov 2022 08:30:33 +0000 (09:30 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 2 Dec 2022 10:13:53 +0000 (10:13 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit f1d2ec4aa86250029fb9189af3bdc52b5fe28ee6)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
t/db_dependent/api/v1/patrons_extended_attributes.t

index 1766576..278631f 100755 (executable)
@@ -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;
 };