Bug 18672: [QA Follow-up] Simplify without sleep
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 23 Jun 2017 10:33:26 +0000 (12:33 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 17 Jul 2017 16:19:43 +0000 (13:19 -0300)
Set the creation date one hour back, store and check again.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Virtualshelves.t

index 4e7e314..dd2b47c 100644 (file)
@@ -43,16 +43,15 @@ subtest 'CRUD' => sub {
     is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' );
     is( output_pref($shelf->created_on), output_pref(dt_from_string), 'The creation time should have been set to today' );
 
-    my $shelf_18672 = Koha::Virtualshelves->find( $shelf->shelfnumber ); # Bug 18672
-    my $created_18672 = $shelf_18672->created_on;
-    sleep 2; # Wait 2 seconds, then store
+    # Test if creation date will not be overwritten by store
+    my $created = dt_from_string->subtract( hours => 1 );
+    $shelf->created_on( $created );
     $shelf->store;
-    $shelf_18672 = Koha::Virtualshelves->find( $shelf->shelfnumber );
-    is($shelf_18672->created_on, $created_18672, 'Creation date is the same after update (Bug 18672)' );
 
     my $retrieved_shelf = Koha::Virtualshelves->find( $shelf->shelfnumber );
 
     is( $retrieved_shelf->shelfname, $shelf->shelfname, 'Find should correctly return the shelfname' );
+    is( dt_from_string($retrieved_shelf->created_on), $created, 'Creation date is the same after update (Bug 18672)' );
 
     # Insert with the same name
     eval {