Bugzilla – Attachment 172878 Details for
Bug 35717
Link suggestions to orders by adding ordernumber to suggestions table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35717: (QA follow-up) ->suggestions() always returns a resultset
Bug-35717-QA-follow-up--suggestions-always-returns.patch (text/plain), 3.03 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-10-17 13:48:59 UTC
(
hide
)
Description:
Bug 35717: (QA follow-up) ->suggestions() always returns a resultset
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-10-17 13:48:59 UTC
Size:
3.03 KB
patch
obsolete
>From 7758f1b8c8908d8691829886048abd1320fb065f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 17 Oct 2024 10:40:49 -0300 >Subject: [PATCH] Bug 35717: (QA follow-up) ->suggestions() always returns a > resultset > >This patch acknowledges the fact a one to many relationship always >returns an iterator (even an empty one) so there's no point in having a >codepath for it not returning a resultset. > >The tests are simplified for readability too. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Acquisition/Order.pm | 6 ++--- > t/db_dependent/Koha/Acquisition/Order.t | 32 ++++++++++++------------- > 2 files changed, 17 insertions(+), 21 deletions(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 2d92e13dd7c..ebfc7a44d9d 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -309,10 +309,8 @@ to the order. > =cut > > sub suggestions { >- my ( $self ) = @_; >- my $rs = $self->_result->suggestions; >- return unless $rs; >- return Koha::Suggestions->_new_from_dbic( $rs ); >+ my ($self) = @_; >+ return Koha::Suggestions->_new_from_dbic( scalar $self->_result->suggestions ); > } > > =head3 current_item_level_holds >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index 3cc320fb034..7c86182c321 100755 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -211,44 +211,42 @@ subtest 'subscription' => sub { > }; > > subtest 'suggestions() tests' => sub { >+ > plan tests => 4; > > $schema->storage->txn_begin; >+ > my $o = $builder->build_object( > { > class => 'Koha::Acquisition::Orders', > } > ); > >- my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); > is( >- ref( $order->suggestions ), 'Koha::Suggestions', >+ ref( $o->suggestions ), 'Koha::Suggestions', > '->suggestions should return a Koha::Suggestions object' > ); > is( >- $order->suggestions->count, 0, >+ $o->suggestions->count, 0, > '->suggestions should return empty set if no linked suggestion' > ); > >- $o = $builder->build_object( >- { >- class => 'Koha::Acquisition::Orders', >- } >- ); >- $o = $builder->build_object( >- { >- class => 'Koha::Suggestions', >- value => { ordernumber => $o->id } >- } >- ); >+ # Add a few suggestions >+ foreach ( 1..3 ) { >+ $builder->build_object( >+ { >+ class => 'Koha::Suggestions', >+ value => { ordernumber => $o->id } >+ } >+ ); >+ } > >- $order = Koha::Acquisition::Orders->find( $o->ordernumber ); > is( >- ref( $order->suggestions ), 'Koha::Suggestions', >+ ref( $o->suggestions ), 'Koha::Suggestions', > '->suggestions should return a Koha::Suggestions object' > ); > is( >- $order->suggestions->count, 1, >+ $o->suggestions->count, 3, > '->suggestions should return linked suggestions' > ); > >-- >2.47.0
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 35717
:
160576
|
160577
|
160578
|
160579
|
160580
|
160581
|
160582
|
160583
|
164834
|
164835
|
164836
|
164837
|
164838
|
164839
|
164840
|
172871
|
172872
|
172873
|
172874
|
172875
|
172876
|
172877
| 172878 |
172899
|
172900
|
172901