Bugzilla – Attachment 171389 Details for
Bug 37902
Timezone ignored when passing rfc3339 formatted date (search 'q')
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37902: Add tests
Bug-37902-Add-tests.patch (text/plain), 3.44 KB, created by
Jonathan Druart
on 2024-09-12 12:56:14 UTC
(
hide
)
Description:
Bug 37902: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-09-12 12:56:14 UTC
Size:
3.44 KB
patch
obsolete
>From 60635cf83d297d57039061f389ab16281ef0fa56 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Sep 2024 12:01:58 +0200 >Subject: [PATCH] Bug 37902: Add tests > >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 76 ++++++++++++++++++++++- > 1 file changed, 75 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index b0eebbd492c..52784d86822 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -23,6 +23,7 @@ use Koha::AuthorisedValues; > use Koha::Cities; > use Koha::Biblios; > use Koha::Patrons; >+use Koha::DateUtils qw(dt_from_string); > > use Mojo::JSON qw(encode_json); > >@@ -139,7 +140,7 @@ get '/cities/:city_id/rs' => sub { > }; > > # The tests >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Mojo; > > use t::lib::Mocks; >@@ -963,3 +964,76 @@ subtest 'objects.find_rs helper' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'date handling' => sub { >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = >+ $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ t::lib::Mocks::mock_userenv( { patron => $patron } ); >+ >+ my $now = dt_from_string(); >+ my $one_hour_ago = $now->clone->subtract( hours => 1 ); >+ my $one_day_ago = $now->clone->subtract( days => 1 ); >+ my $one_day_later = $now->clone->add( hours => 1 ); >+ >+ # one hour ago job >+ my $job_1 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_hour_ago, >+ data => '{}', >+ } >+ } >+ ); >+ >+ # yesterday job >+ my $job_2 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_day_ago, >+ data => '{}', >+ } >+ } >+ ); >+ >+ # tomorrow job >+ my $job_3 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_day_later, >+ data => '{}', >+ } >+ } >+ ); >+ >+ my $t = Test::Mojo->new('Koha::REST::V1'); >+ my $q = encode_json( { enqueued_on => $one_hour_ago->rfc3339, borrowernumber => $patron->id } ); >+ $t->get_ok( "//$userid:$password@/api/v1/jobs?q=" . $q )->status_is(200)->json_is( '/0/job_id' => $job_1->id ); >+ my $response_count = scalar @{ $t->tx->res->json }; >+ is( $response_count, 1 ); >+ >+ $q = encode_json( >+ { >+ enqueued_on => [ { '>' => $now->rfc3339 }, { '=' => $one_hour_ago->rfc3339 } ], >+ borrowernumber => $patron->id >+ } >+ ); >+ $t->get_ok( "//$userid:$password@/api/v1/jobs?q=" . $q )->status_is(200)->json_is( '/0/job_id' => $job_1->id ) >+ ->json_is( '/1/job_id' => $job_3->id ); >+ $response_count = scalar @{ $t->tx->res->json }; >+ is( $response_count, 2 ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37902
:
171389
|
171390
|
171391
|
171392
|
171402
|
171403
|
171515
|
171551
|
171652
|
171762
|
171763
|
171764
|
171765
|
171766
|
171767
|
171768
|
172105
|
172106
|
172107
|
172108
|
172109
|
172110
|
172111
|
172112