Bugzilla – Attachment 185086 Details for
Bug 39900
Add public REST endpoint for additional_contents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39900: (QA follow-up): Add translated_contents to tests
Bug-39900-QA-follow-up-Add-translatedcontents-to-t.patch (text/plain), 4.29 KB, created by
Marcel de Rooy
on 2025-08-04 08:17:06 UTC
(
hide
)
Description:
Bug 39900: (QA follow-up): Add translated_contents to tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-08-04 08:17:06 UTC
Size:
4.29 KB
patch
obsolete
>From 733aa985d11a8578c608d6ede0f75a0853514e56 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Fri, 1 Aug 2025 10:52:58 +0000 >Subject: [PATCH] Bug 39900: (QA follow-up): Add translated_contents to tests >Content-Type: text/plain; charset=utf-8 > >Also add tests to searching for specific language code > >prove t/db_dependent/api/v1/additional_contents.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Schema/Result/AdditionalContent.pm | 8 ++- > t/db_dependent/api/v1/additional_contents.t | 62 ++++++++++++++++++++- > 2 files changed, 68 insertions(+), 2 deletions(-) > >diff --git a/Koha/Schema/Result/AdditionalContent.pm b/Koha/Schema/Result/AdditionalContent.pm >index c559107ca7..ab2022c501 100644 >--- a/Koha/Schema/Result/AdditionalContent.pm >+++ b/Koha/Schema/Result/AdditionalContent.pm >@@ -235,5 +235,11 @@ __PACKAGE__->belongs_to( > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0w/fOUAy+4V4aVls/i7Wig > > >-# You can replace this text with custom code or comments, and it will be preserved on regeneration >+__PACKAGE__->has_many( >+ "translated_contents", >+ "Koha::Schema::Result::AdditionalContentsLocalization", >+ { "foreign.additional_content_id" => "self.id" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > 1; >diff --git a/t/db_dependent/api/v1/additional_contents.t b/t/db_dependent/api/v1/additional_contents.t >index 3d1b4ef369..6734746d5a 100755 >--- a/t/db_dependent/api/v1/additional_contents.t >+++ b/t/db_dependent/api/v1/additional_contents.t >@@ -35,7 +35,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > subtest 'anonymous access' => sub { >- plan tests => 9; >+ plan tests => 17; > > $schema->storage->txn_begin; > >@@ -80,6 +80,26 @@ subtest 'anonymous access' => sub { > } > ); > >+ $builder->build_object( >+ { >+ class => 'Koha::AdditionalContentsLocalizations', >+ value => { >+ additional_content_id => $public_additional_contents->id, >+ lang => 'pt-PT', >+ } >+ } >+ ); >+ >+ $builder->build_object( >+ { >+ class => 'Koha::AdditionalContentsLocalizations', >+ value => { >+ additional_content_id => $public_additional_contents->id, >+ lang => 'es-ES', >+ } >+ } >+ ); >+ > $res = $t->get_ok("/api/v1/public/additional_contents")->status_is(200)->tx->res->json; > > is( scalar @{$res}, 1, 'There is now one active and public additional content' ); >@@ -92,6 +112,46 @@ subtest 'anonymous access' => sub { > } > ); > >+ my $second_public_additional_contents = $builder->build_object( >+ { >+ class => 'Koha::AdditionalContents', >+ value => { >+ expirationdate => $tomorrow, >+ published_on => $yesterday, >+ category => 'news', >+ location => 'staff_and_opac', >+ branchcode => undef, >+ number => 3, >+ } >+ } >+ ); >+ >+ $builder->build_object( >+ { >+ class => 'Koha::AdditionalContentsLocalizations', >+ value => { >+ additional_content_id => $second_public_additional_contents->id, >+ lang => 'fr-FR', >+ } >+ } >+ ); >+ >+ $t->get_ok( "/api/v1/public/additional_contents?q={\"translated_contents.lang\": \"pt-PT\"}" => >+ { 'x-koha-embed' => 'translated_contents' } )->status_is(200)->json_is( >+ '/0' => { >+ %{ $public_additional_contents->to_api( { public => 1 } ) }, >+ translated_contents => $public_additional_contents->translated_contents->to_api( { public => 1 } ) >+ } >+ )->json_hasnt('/1'); >+ >+ $t->get_ok( "/api/v1/public/additional_contents?q={\"translated_contents.lang\": \"fr-FR\"}" => >+ { 'x-koha-embed' => 'translated_contents' } )->status_is(200)->json_is( >+ '/0' => { >+ %{ $second_public_additional_contents->to_api( { public => 1 } ) }, >+ translated_contents => $second_public_additional_contents->translated_contents->to_api( { public => 1 } ) >+ } >+ )->json_hasnt('/1'); >+ > $schema->storage->txn_rollback; > > }; >-- >2.39.5
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 39900
:
182439
|
182440
|
182441
|
182442
|
182443
|
182887
|
182888
|
182889
|
182890
|
182891
|
184722
|
184723
|
184724
|
184725
|
184726
|
184978
|
184979
|
185081
|
185082
|
185083
|
185084
|
185085
| 185086 |
185453
|
185455