Bugzilla – Attachment 166392 Details for
Bug 36758
We should notify an assignee when they are assigned a ticket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36758: Unit tests for assignee notification trigger
Bug-36758-Unit-tests-for-assignee-notification-tri.patch (text/plain), 3.79 KB, created by
David Nind
on 2024-05-08 12:03:50 UTC
(
hide
)
Description:
Bug 36758: Unit tests for assignee notification trigger
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-05-08 12:03:50 UTC
Size:
3.79 KB
patch
obsolete
>From a4b64ab52f272f7802727d1ec51599174849022c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 7 May 2024 17:16:57 +0100 >Subject: [PATCH] Bug 36758: Unit tests for assignee notification trigger > >This patch adds unit tests for the TICKET_ASSIGNED trigger being >introduced with this patchset. > >Test plan >1) Run the unit tests prior to the next patch and confirm they fail >2) Apply the next patch and confirm the unit tests now pass > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Ticket.t | 64 +++++++++++++++++++++++++++++++++++- > 1 file changed, 63 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Ticket.t b/t/db_dependent/Koha/Ticket.t >index cc1798ef19..d559d01d15 100755 >--- a/t/db_dependent/Koha/Ticket.t >+++ b/t/db_dependent/Koha/Ticket.t >@@ -169,7 +169,7 @@ subtest 'add_update() tests' => sub { > }; > > subtest 'store() tests' => sub { >- plan tests => 2; >+ plan tests => 3; > > subtest 'acknowledgement notice trigger' => sub { > plan tests => 4; >@@ -247,6 +247,68 @@ subtest 'store() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'assignment notice trigger' => sub { >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => "Koha::Patrons" } ); >+ my $assignee = $builder->build_object( { class => "Koha::Patrons" } ); >+ my $biblio = $builder->build_sample_biblio(); >+ >+ my $librarian = $builder->build_object( { class => "Koha::Patrons" } ); >+ t::lib::Mocks::mock_userenv({ patron => $librarian }); >+ >+ my $new_ticket = Koha::Ticket->new( >+ { >+ reporter_id => $patron->id, >+ assignee_id => $assignee->id, >+ title => "Testing ticket", >+ body => "Testing ticket message", >+ biblio_id => $biblio->id >+ } >+ )->store(); >+ >+ is( ref($new_ticket), 'Koha::Ticket', >+ 'Koha::Ticket->store() returned the Koha::Ticket object' ); >+ my $notices = >+ Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); >+ is( $notices->count, 1, >+ 'One assignement notice queued for the ticket assignee at ticket creation' ); >+ my $THE_notice = $notices->next; >+ isnt( $THE_notice->status, 'pending', >+ 'Assignment notice is sent immediately' ); >+ >+ $new_ticket->set( { title => "Changed title" } )->store(); >+ $notices = >+ Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); >+ is( $notices->count, 1, >+ "Further assignment notices are not queud for subsequent stores that don't set assignee" >+ ); >+ >+ $new_ticket->set({ assignee_id => $assignee->id })->store(); >+ $notices = >+ Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); >+ is( $notices->count, 1, >+ "Further assignment notices are not queud for subsequent stores that don't change assignee" >+ ); >+ >+ my $assignee2 = $builder->build_object( { class => "Koha::Patrons" } ); >+ $new_ticket->set({ assignee_id => $assignee2->id })->store(); >+ $notices = >+ Koha::Notice::Messages->search( { borrowernumber => $assignee2->id } ); >+ is( $notices->count, 1, >+ 'New assignement notice queued for a change of ticket assignee' ); >+ >+ $new_ticket->set({ assignee_id => $librarian->id })->store(); >+ $notices = >+ Koha::Notice::Messages->search( { borrowernumber => $librarian->id } ); >+ is( $notices->count, 0, >+ 'Assignment notice not queued for self-assignments' ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'strings_map() tests' => sub { >-- >2.39.2
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 36758
:
166316
|
166317
|
166318
|
166319
|
166390
|
166391
|
166392
|
166393
|
169238
|
169239
|
169240
|
169241
|
170226