Bugzilla – Attachment 185282 Details for
Bug 39721
Remove GetSuggestion from C4/Suggestions.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39721: (follow-up) Remove unblessed
Bug-39721-follow-up-Remove-unblessed.patch (text/plain), 9.63 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-08-08 14:38:31 UTC
(
hide
)
Description:
Bug 39721: (follow-up) Remove unblessed
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-08-08 14:38:31 UTC
Size:
9.63 KB
patch
obsolete
>From 7b928888a3e6ef2a31909f073fe8446741c3deba Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Fri, 8 Aug 2025 14:22:46 +0000 >Subject: [PATCH] Bug 39721: (follow-up) Remove unblessed > >--- > t/db_dependent/Suggestions.t | 68 ++++++++++++++++++------------------ > 1 file changed, 34 insertions(+), 34 deletions(-) > >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 87c3f6dffd..de69d0bb3e 100755 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -177,16 +177,16 @@ isnt( $my_suggestionid, 0, 'Suggestion is correctly saved' ); > my $my_suggestion_with_budget_object = Koha::Suggestion->new($my_suggestion_with_budget)->store; > my $my_suggestionid_with_budget = $my_suggestion_with_budget_object->id; > >-my $suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >-is( $suggestion->{title}, $my_suggestion->{title}, 'Suggestion stores the title correctly' ); >-is( $suggestion->{author}, $my_suggestion->{author}, 'Suggestion stores the author correctly' ); >-is( $suggestion->{publishercode}, $my_suggestion->{publishercode}, 'Suggestion stores the publishercode correctly' ); >-is( $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, 'Suggestion stores the borrower number correctly' ); >-is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'Suggestion stores the biblio number correctly' ); >-is( $suggestion->{STATUS}, 'ASKED', 'Suggestion stores a suggestion with the status ASKED by default' ); >-is( $suggestion->{managedby}, undef, 'Suggestion stores empty string as undef for non existent foreign key (integer)' ); >-is( $suggestion->{manageddate}, undef, 'Suggestion stores empty string as undef for date' ); >-is( $suggestion->{budgetid}, undef, 'Suggestion should set budgetid to NULL if not given' ); >+my $suggestion = Koha::Suggestions->find($my_suggestionid); >+is( $suggestion->title, $my_suggestion->{title}, 'Suggestion stores the title correctly' ); >+is( $suggestion->author, $my_suggestion->{author}, 'Suggestion stores the author correctly' ); >+is( $suggestion->publishercode, $my_suggestion->{publishercode}, 'Suggestion stores the publishercode correctly' ); >+is( $suggestion->suggestedby, $my_suggestion->{suggestedby}, 'Suggestion stores the borrower number correctly' ); >+is( $suggestion->biblionumber, $my_suggestion->{biblionumber}, 'Suggestion stores the biblio number correctly' ); >+is( $suggestion->STATUS, 'ASKED', 'Suggestion stores a suggestion with the status ASKED by default' ); >+is( $suggestion->managedby, undef, 'Suggestion stores empty string as undef for non existent foreign key (integer)' ); >+is( $suggestion->manageddate, undef, 'Suggestion stores empty string as undef for date' ); >+is( $suggestion->budgetid, undef, 'Suggestion should set budgetid to NULL if not given' ); > > is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' ); > my $mod_suggestion1 = { >@@ -202,20 +202,20 @@ is( $status, undef, 'ModSuggestion without the suggestion id returns undef' ); > $mod_suggestion1->{suggestionid} = $my_suggestionid; > $status = ModSuggestion($mod_suggestion1); > is( $status, 1, 'ModSuggestion modifies one entry' ); >-$suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >-is( $suggestion->{title}, $mod_suggestion1->{title}, 'ModSuggestion modifies the title correctly' ); >-is( $suggestion->{author}, $mod_suggestion1->{author}, 'ModSuggestion modifies the author correctly' ); >+$suggestion = Koha::Suggestions->find($my_suggestionid); >+is( $suggestion->title, $mod_suggestion1->{title}, 'ModSuggestion modifies the title correctly' ); >+is( $suggestion->author, $mod_suggestion1->{author}, 'ModSuggestion modifies the author correctly' ); > is( >- $suggestion->{publishercode}, $mod_suggestion1->{publishercode}, >+ $suggestion->publishercode, $mod_suggestion1->{publishercode}, > 'ModSuggestion modifies the publishercode correctly' > ); > is( >- $suggestion->{managedby}, undef, >+ $suggestion->managedby, undef, > 'ModSuggestion stores empty string as undef for non existent foreign key (integer)' > ); >-is( $suggestion->{manageddate}, undef, 'ModSuggestion stores empty string as undef for date' ); >-isnt( $suggestion->{accepteddate}, undef, 'ModSuggestion does not update a non given date value' ); >-is( $suggestion->{note}, 'my note', 'ModSuggestion should not erase data if not given' ); >+is( $suggestion->manageddate, undef, 'ModSuggestion stores empty string as undef for date' ); >+isnt( $suggestion->accepteddate, undef, 'ModSuggestion does not update a non given date value' ); >+is( $suggestion->note, 'my note', 'ModSuggestion should not erase data if not given' ); > > my $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); > is( @$messages, 0, 'ModSuggestions does not send an email if the status is not updated' ); >@@ -246,8 +246,8 @@ my $mod_suggestion3 = { > t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 0 ); > $status = ModSuggestion($mod_suggestion3); > is( $status, 1, 'ModSuggestion modifies one entry' ); >-$suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >-is( $suggestion->{STATUS}, $mod_suggestion3->{STATUS}, 'ModSuggestion modifies the status correctly' ); >+$suggestion = Koha::Suggestions->find($my_suggestionid); >+is( $suggestion->STATUS, $mod_suggestion3->{STATUS}, 'ModSuggestion modifies the status correctly' ); > $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); > is( @$messages, 1, 'ModSuggestion sends an email if the status is updated' ); > is( >@@ -437,9 +437,9 @@ is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arg > my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } ); > my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber ); > is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' ); >-$suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >+$suggestion = Koha::Suggestions->find($my_suggestionid); > is( >- $suggestion->{biblionumber}, $biblio_2->biblionumber, >+ $suggestion->biblionumber, $biblio_2->biblionumber, > 'ConnectSuggestionAndBiblio updates the biblio number correctly' > ); > >@@ -468,13 +468,13 @@ is( $suggestions->[1]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes > $my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB > my $my_suggestionid_test_budget_object = Koha::Suggestion->new($my_suggestion)->store; > my $my_suggestionid_test_budgetid = $my_suggestionid_test_budget_object->id; >-$suggestion = Koha::Suggestions->find($my_suggestionid_test_budgetid)->unblessed(); >-is( $suggestion->{budgetid}, undef, 'Suggestion Should set budgetid to NULL if equals an empty string' ); >+$suggestion = Koha::Suggestions->find($my_suggestionid_test_budgetid); >+is( $suggestion->budgetid, undef, 'Suggestion Should set budgetid to NULL if equals an empty string' ); > > $my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB > ModSuggestion($my_suggestion); >-$suggestion = Koha::Suggestions->find($my_suggestionid_test_budgetid)->unblessed(); >-is( $suggestion->{budgetid}, undef, 'Suggestion Should set budgetid to NULL if equals an empty string' ); >+$suggestion = Koha::Suggestions->find($my_suggestionid_test_budgetid); >+is( $suggestion->budgetid, undef, 'Suggestion Should set budgetid to NULL if equals an empty string' ); > > my $suggestion2 = { > title => "Cuisine d'automne", >@@ -510,11 +510,11 @@ subtest 'GetUnprocessedSuggestions' => sub { > 'GetUnprocessedSuggestions should return 0 if a suggestion has been processed but not linked to a fund' > ); > my $status = ModSuggestion($mod_suggestion1); >- my $suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >- is( $suggestion->{budgetid}, undef, 'ModSuggestion should set budgetid to NULL if not given' ); >+ my $suggestion = Koha::Suggestions->find($my_suggestionid); >+ is( $suggestion->budgetid, undef, 'ModSuggestion should set budgetid to NULL if not given' ); > ModSuggestion( { suggestionid => $my_suggestionid, budgetid => $budget_id } ); >- $suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >- is( $suggestion->{budgetid}, $budget_id, 'ModSuggestion should modify budgetid if given' ); >+ $suggestion = Koha::Suggestions->find($my_suggestionid); >+ is( $suggestion->budgetid, $budget_id, 'ModSuggestion should modify budgetid if given' ); > > $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; > is( >@@ -733,8 +733,8 @@ subtest 'ModSuggestion should work on suggestions without a suggester' => sub { > > $dbh->do(q|DELETE FROM suggestions|); > my $my_suggestionid = Koha::Suggestion->new($my_suggestion_without_suggestedby)->store()->id; >- $suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >- is( $suggestion->{suggestedby}, undef, "Suggestedby is undef" ); >+ $suggestion = Koha::Suggestions->find($my_suggestionid); >+ is( $suggestion->suggestedby, undef, "Suggestedby is undef" ); > > ModSuggestion( > { >@@ -743,9 +743,9 @@ subtest 'ModSuggestion should work on suggestions without a suggester' => sub { > note => "Test note" > } > ); >- $suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed(); >+ $suggestion = Koha::Suggestions->find($my_suggestionid); > >- is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" ); >+ is( $suggestion->note, "Test note", "ModSuggestion works on suggestions without a suggester" ); > }; > > subtest 'place_hold tests' => sub { >-- >2.43.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 39721
:
181402
|
181416
|
182810
|
185280
|
185281
| 185282 |
185283