Bug 25296: Unit tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Apr 2020 21:32:50 +0000 (18:32 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 29 Apr 2020 17:59:59 +0000 (18:59 +0100)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
t/db_dependent/Koha/Objects.t

index c5ac1ba..2af778a 100644 (file)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 21;
+use Test::More tests => 22;
 use Test::Exception;
 use Test::Warn;
 
@@ -799,3 +799,20 @@ subtest 'prefetch_whitelist() tests' => sub {
 
     $schema->storage->txn_rollback;
 };
+
+subtest 'empty() tests' => sub {
+
+    plan tests => 3;
+
+    $schema->storage->txn_begin;
+
+    # Add a patron, we need more than 0
+    $builder->build_object({ class => 'Koha::Patrons' });
+    ok( Koha::Patrons->count > 0, 'There is more than one Koha::Patron on the resultset' );
+
+    my $empty = Koha::Patrons->new->empty;
+    is( ref($empty), 'Koha::Patrons', '->empty returns a Koha::Patrons iterator' );
+    is( $empty->count, 0, 'The empty resultset is, well, empty :-D' );
+
+    $schema->storage->txn_rollback;
+};