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 <martin.renvoize@ptfs-europe.com>

JD amended patch:
  FAIL   spelling
    formated ==> formatted

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2021-10-21 16:08:19 +01:00 committed by Kyle M Hall
parent 0266164580
commit 76d66cc9ad
1 changed files with 11 additions and 11 deletions

View File

@ -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 formatted date string, a date field is converted into an SQL formatted date string'
);
$attrs = $patron->attributes_from_api(