From 5f172fa95293477ce9979f1a0bba889fba02f7f7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 21 Oct 2021 16:08:19 +0100 Subject: [PATCH] Bug 28585: (QA follow-up) Fix object.t Object.t was still testing for the return of DateTime objects from attributes_from_api. I checked all calls to attrbutes_from_api for reliance of DateTime objects and confirmed they all get passed into search calls and thus are better served as SQL formatted strings. I then converted the test to check that the rfc3339 formatted dates passed in were converted to strings appropriate for feeding into SQL where statements instead. Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Object.t | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 8004c26446..8a034a36b0 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -530,8 +530,8 @@ subtest 'attributes_from_api() tests' => sub { my $attrs = $patron->attributes_from_api( { - updated_on => '2019-12-27T14:53:00', - last_seen => '2019-12-27T14:53:00', + updated_on => '2019-12-27T14:53:00Z', + last_seen => '2019-12-27T14:53:00Z', date_of_birth => '2019-12-27', } ); @@ -539,25 +539,25 @@ subtest 'attributes_from_api() tests' => sub { ok( exists $attrs->{updated_on}, 'No translation takes place if no mapping' ); is( - ref( $attrs->{updated_on} ), - 'DateTime', - 'Given a string, a timestamp field is converted into a DateTime object' + $attrs->{updated_on}, + '2019-12-27 14:53:00', + 'Given an rfc3339 formatted datetime string, a timestamp field is converted into an SQL formatted datetime string' ); ok( exists $attrs->{lastseen}, 'Translation takes place because of the defined mapping' ); is( - ref( $attrs->{lastseen} ), - 'DateTime', - 'Given a string, a datetime field is converted into a DateTime object' + $attrs->{lastseen}, + '2019-12-27 14:53:00', + 'Given an rfc3339 formatted datetime string, a datetime field is converted into an SQL formatted datetime string' ); ok( exists $attrs->{dateofbirth}, 'Translation takes place because of the defined mapping' ); is( - ref( $attrs->{dateofbirth} ), - 'DateTime', - 'Given a string, a date field is converted into a DateTime object' + $attrs->{dateofbirth}, + '2019-12-27', + 'Given an rfc3339 formated date string, a date field is converted into an SQL formatted date string' ); $attrs = $patron->attributes_from_api( -- 2.20.1