Bug 20584: Prevent Koha/Patron/Categories.t to fail randomly
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 13 Apr 2018 18:09:53 +0000 (15:09 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 13 Apr 2018 18:09:56 +0000 (15:09 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/Patron/Categories.t

index 6a0171f..58882a4 100644 (file)
@@ -26,6 +26,7 @@ use Koha::Database;
 use Koha::DateUtils;
 use Koha::Patron::Category;
 use Koha::Patron::Categories;
+use t::lib::Dates;
 use t::lib::TestBuilder;
 use t::lib::Mocks;
 
@@ -75,11 +76,11 @@ subtest 'get_expiry_date' => sub {
     is( $category->get_expiry_date( $next_year ), $next_month, 'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given' );
 
     $category->enrolmentperiod( 12 )->store;
-    is( $category->get_expiry_date, $next_year, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
-    is( $category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 ), 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
+    is( t::lib::Dates::compare($category->get_expiry_date, $next_year), 0, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
+    is( t::lib::Dates::compare($category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 )), 0, 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
 
     my $hardcoded_date = '2000-01-31';
-    is( $category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 ), 'get_expiry_date accepts strings as well'  );
+    is( t::lib::Dates::compare($category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 )), 0, 'get_expiry_date accepts strings as well'  );
 
     $category->delete;
 };