Bugzilla – Attachment 190910 Details for
Bug 39934
Standard backend shows attributes from previously "migrated from" backends
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39934: Add tests
Bug-39934-Add-tests.patch (text/plain), 5.29 KB, created by
David Nind
on 2026-01-05 18:56:54 UTC
(
hide
)
Description:
Bug 39934: Add tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2026-01-05 18:56:54 UTC
Size:
5.29 KB
patch
obsolete
>From 904a0d9a379c5828b63e668a5a79b6a06c746ebc Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Mon, 19 May 2025 10:13:15 +0000 >Subject: [PATCH] Bug 39934: Add tests > >prove t/db_dependent/Koha/ILL/Backend/Standard.t > >Test plan, k-t-d, don't apply patches yet: >1) Enable ILLModule sys pref >2) Install an additional backend, e.g. ReprintsDesk: >https://github.com/openfifth/koha-ill-reprintsdesk/releases/tag/v4.0.3 >3) Restart plack >$ koha-plack --restart kohadev >4) Create a new ReprintsDesk request, visit: ><staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=ReprintsDesk >5) Enter DOI: '123', 'First page of article in journal': 'abc', a cardnumber '42' and a library. Click 'Make request' >6) Click 'Switch provider'. Pick 'Standard'. >7) Notice 'First page of article in journal' shows. This is confusing as it means nothing in the 'Standard' context. >8) Apply patches. Repeat test plan. The attributes from the previous backend still exist in the database, but the UI now only shows attributes relevant to the current backend of the request. To confirm this, run: >$ koha-mysql kohadev >$ select * from illrequestattributes; > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/ILL/Backend/Standard.t | 105 ++++++++++++++++++++- > 1 file changed, 102 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Koha/ILL/Backend/Standard.t b/t/db_dependent/Koha/ILL/Backend/Standard.t >index 94193aa941..16a207abeb 100755 >--- a/t/db_dependent/Koha/ILL/Backend/Standard.t >+++ b/t/db_dependent/Koha/ILL/Backend/Standard.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::MockModule; > use Test::NoWarnings; > >@@ -116,12 +116,12 @@ subtest 'edititem() tests' => sub { > > subtest 'metadata() tests' => sub { > >- plan tests => 8; >+ plan tests => 13; > > $schema->storage->txn_begin; > > # Create a test ILL request >- my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } ); >+ my $request = $builder->build_sample_ill_request( { backend => 'Standard' } ); > > # Add various attributes including some that should be ignored > $request->add_or_update_attributes( >@@ -157,5 +157,104 @@ subtest 'metadata() tests' => sub { > ok( !exists $metadata->{Requested_partners}, 'requested_partners excluded from metadata' ); > ok( !exists $metadata->{Copyrightclearance_confirmed}, 'copyrightclearance_confirmed excluded from metadata' ); > >+ my $new_request = $builder->build_sample_ill_request( { backend => 'Standard' } ); >+ >+ is( >+ scalar %{ $new_request->metadata }, 0, >+ 'metadata() returns empty if no metadata is set' >+ ); >+ >+ $builder->build_object( >+ { >+ class => 'Koha::ILL::Request::Attributes', >+ value => { >+ illrequest_id => $new_request->illrequest_id, >+ type => 'title', >+ value => 'The Hobbit', >+ backend => 'Standard', >+ } >+ } >+ ); >+ >+ is( >+ scalar %{ $new_request->metadata }, 1, >+ 'metadata() returns non-empty if metadata is set' >+ ); >+ >+ $builder->build_object( >+ { >+ class => 'Koha::ILL::Request::Attributes', >+ value => { >+ illrequest_id => $new_request->illrequest_id, >+ type => 'author', >+ value => 'JRR Tolkien', >+ backend => 'Other_backend', >+ } >+ } >+ ); >+ >+ is( >+ scalar %{ $new_request->metadata }, 1, >+ 'metadata() only returns attributes from Standard' >+ ); >+ >+ is( >+ $new_request->metadata->{'Title'}, 'The Hobbit', >+ 'metadata() only returns attributes from Standard' >+ ); >+ >+ is( >+ $new_request->metadata->{'Author'}, undef, >+ 'metadata() only returns attributes from Standard' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'migrate() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $request = $builder->build_sample_ill_request( { backend => 'Other_backend' } ); >+ >+ # Add attribute that Standard does not consider metadata >+ $builder->build_object( >+ { >+ class => 'Koha::ILL::Request::Attributes', >+ value => { >+ illrequest_id => $request->illrequest_id, >+ type => 'Not_Standard_field', >+ value => 'test', >+ backend => 'Other_backend', >+ } >+ } >+ ); >+ >+ # Add attribute that Standard considers metadata >+ $builder->build_object( >+ { >+ class => 'Koha::ILL::Request::Attributes', >+ value => { >+ illrequest_id => $request->illrequest_id, >+ type => 'DOI', >+ value => '123/abc', >+ backend => 'Other_backend', >+ } >+ } >+ ); >+ >+ my $test = $request->backend_migrate( >+ { >+ backend => 'Standard', >+ illrequest_id => $request->illrequest_id >+ } >+ ); >+ >+ is( $request->metadata->{'Not_Standard_field'}, undef, 'Non standard field not migrated' ); >+ >+ is( $request->metadata->{'DOI'}, '123/abc', 'Standard field migrated' ); >+ > $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 39934
:
182581
|
182582
|
182583
|
190887
|
190888
|
190889
|
190908
|
190909
| 190910