Bugzilla – Attachment 156545 Details for
Bug 33690
Add ability to send welcome notice when creating patrons using the REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33690: (QA follow-up) Mock C4::Letters subroutines for unit tests
Bug-33690-QA-follow-up-Mock-C4Letters-subroutines-.patch (text/plain), 2.32 KB, created by
Jonathan Druart
on 2023-10-04 13:54:02 UTC
(
hide
)
Description:
Bug 33690: (QA follow-up) Mock C4::Letters subroutines for unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-10-04 13:54:02 UTC
Size:
2.32 KB
patch
obsolete
>From 8cc20b80433592ccc3003e1c68d3cb546aa1a78c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 23 Jun 2023 10:50:33 -0400 >Subject: [PATCH] Bug 33690: (QA follow-up) Mock C4::Letters subroutines for > unit tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >JD Amended patch: tidy > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/api/v1/patrons.t | 29 ++++++++++++++++++++++++++++- > 1 file changed, 28 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index bad403db8ea..0d98ad0c982 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -45,6 +45,32 @@ my $builder = t::lib::TestBuilder->new; > my $t = Test::Mojo->new('Koha::REST::V1'); > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > >+### Mock Letters >+my $mocked_letters = Test::MockModule->new('C4::Letters'); >+$mocked_letters->mock( >+ 'GetPreparedLetter', >+ sub { >+ return 1; >+ } >+); >+my $letter_enqueued; >+$mocked_letters->mock( >+ 'EnqueueLetter', >+ sub { >+ $letter_enqueued = 1; >+ >+ # return a 'message_id' >+ return 42; >+ } >+); >+$mocked_letters->mock( >+ 'SendQueuedMessages', >+ sub { >+ my $params = shift; >+ return 1; >+ } >+); >+ > subtest 'list() tests' => sub { > > plan tests => 3; >@@ -382,6 +408,7 @@ subtest 'add() tests' => sub { > # Set a date-time field > $newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); > >+ $letter_enqueued = 0; > $t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron) > ->status_is(201, 'Patron created successfully') > ->header_like( >@@ -396,7 +423,7 @@ subtest 'add() tests' => sub { > ->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); > > my $p = Koha::Patrons->find( { cardnumber => $newpatron->{cardnumber} } ); >- is( Koha::Notice::Messages->search({ borrowernumber => $p->borrowernumber })->count, 1 , "Patron got welcome notice" ); >+ is( $letter_enqueued, 1 , "Patron got welcome notice" ); > > $newpatron->{userid} = undef; # force regeneration > warning_like { >-- >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 33690
:
150777
|
150787
|
150791
|
152642
|
155396
|
155397
|
155398
|
155406
|
155407
|
156544
| 156545 |
156546