To reproduce: - Run (on master) $ prove t/db_dependent/Contract.t => FAIL: tests fail due to a fixed date (2015-07-31) being set as a future date which hasn't arrived yet.
Created attachment 41682 [details] [review] Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D
Comment on attachment 41682 [details] [review] Bug 14693: Contract.t should generate dates based on current date Review of attachment 41682 [details] [review]: ----------------------------------------------------------------- ::: t/db_dependent/Contract.t @@ +72,5 @@ > is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' ); > is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' ); > > +my $now = dt_from_string; > +my $three_more_days = $now + DateTime::Duration->new( days => 3 ); 1/ DateTime::Duration should be imported 2/ Are you sure this works ? There are the 2 add_duration or subtract_duration methods, which is certainly better.
(In reply to Jonathan Druart from comment #2) > Comment on attachment 41682 [details] [review] [review] > 1/ DateTime::Duration should be imported I agree. Will fix it now. > 2/ Are you sure this works ? There are the 2 add_duration or > subtract_duration methods, which is certainly better. It is just syntax sugar. Using the plus symbol is correctly documented on DateTime: $dt2 = $dt + $duration_object; $dt3 = $dt - $duration_object; I think it provides better readability.
Created attachment 41715 [details] [review] Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration,
Created attachment 41785 [details] [review] [SIGNED-OFF] Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration, Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 41786 [details] [review] Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration, Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix pushed to master.