Bug 38526: (bug 36822 follow-up): Improve datetime comparison in tests
17:39:54 koha_1 | # Failed test 'updated_on correctly saved on newly created user'
17:39:54 koha_1 | # at t/db_dependent/Auth_with_shibboleth.t line 319.
17:39:54 koha_1 | # Structures begin differing at:
17:39:54 koha_1 | # $got->[0] = '2024-11-19 16:39:30'
17:39:54 koha_1 | # $expected->[0] = '2024-11-19 16:39:29'
17:39:54 koha_1 | # Looks like you failed 1 test of 54.
We must use t::lib::Dates::compare to compare datetimes in tests.
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit ed25a48ccf)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
dd6240343a
commit
3b31cf80c3
|
|
@ -20,9 +20,11 @@ use Modern::Perl;
|
|||
use Test::More tests => 4;
|
||||
use Test::MockModule;
|
||||
use Test::MockObject;
|
||||
use Test::Warn;
|
||||
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
use Test::Warn;
|
||||
use t::lib::Dates;
|
||||
|
||||
use C4::Context;
|
||||
use C4::Auth;
|
||||
|
|
@ -276,11 +278,10 @@ subtest 'checkpw_ldap tests' => sub {
|
|||
$welcome = 0;
|
||||
|
||||
# replicate testing with checkpw
|
||||
my $time_now = dt_from_string()->ymd . ' ' . dt_from_string()->hms;
|
||||
C4::Auth::checkpw( 'hola', password => 'hey' );
|
||||
my $patron_replicated_from_auth = Koha::Patrons->search( { userid => 'hola' } )->next;
|
||||
is(
|
||||
$patron_replicated_from_auth->updated_on, $time_now,
|
||||
t::lib::Dates::compare( $patron_replicated_from_auth->updated_on, dt_from_string ), 0,
|
||||
"updated_on correctly saved on newly created user"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use File::Temp qw(tempdir);
|
|||
use t::lib::Mocks;
|
||||
use t::lib::Mocks::Logger;
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Dates;
|
||||
|
||||
use C4::Auth_with_shibboleth qw( shib_ok login_shib_url get_login_shib checkpw_shib );
|
||||
use Koha::Database;
|
||||
|
|
@ -288,15 +289,14 @@ subtest "checkpw_shib tests" => sub {
|
|||
$ENV{'emailpro'} = 'me@myemail.com';
|
||||
$ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint
|
||||
|
||||
my $time_now = dt_from_string()->ymd . ' ' . dt_from_string()->hms;
|
||||
checkpw($shib_login);
|
||||
ok my $new_user_autocreated = $schema->resultset('Borrower')->search( { 'userid' => 'test43210' }, { rows => 1 } ),
|
||||
"new user found";
|
||||
ok(
|
||||
my $new_user_autocreated = Koha::Patrons->find( { userid => 'test43210' } ),
|
||||
"new user found"
|
||||
);
|
||||
|
||||
my $rec_autocreated = $new_user_autocreated->next;
|
||||
is_deeply(
|
||||
[ map { $rec_autocreated->$_ } qw/updated_on/ ],
|
||||
[$time_now],
|
||||
is(
|
||||
t::lib::Dates::compare( $new_user_autocreated->updated_on, dt_from_string ), 0,
|
||||
'updated_on correctly saved on newly created user'
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue