Bugzilla – Attachment 95461 Details for
Bug 24016
manager_id in Koha::Patron::Message->store should not depend on userenv alone
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24016: Add a failing test for overwrite-able manager_id in Koha::Patron::Message
Bug-24016-Add-a-failing-test-for-overwrite-able-ma.patch (text/plain), 4.65 KB, created by
Maryse Simard
on 2019-11-15 19:24:13 UTC
(
hide
)
Description:
Bug 24016: Add a failing test for overwrite-able manager_id in Koha::Patron::Message
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2019-11-15 19:24:13 UTC
Size:
4.65 KB
patch
obsolete
>From 6f0e59895d3b87bd9ce4b67aa8a574c249f23a56 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Tue, 12 Nov 2019 12:24:30 +0000 >Subject: [PATCH] Bug 24016: Add a failing test for overwrite-able manager_id > in Koha::Patron::Message > >To test: >1. prove t/db_dependent/Koha/Patron/Messages.t >2. Observe failure > >t/db_dependent/Koha/Patron/Messages.t .. 2/12 > Failed test 'Manager id should be overwrite-able even if defined in userenv' > at t/db_dependent/Koha/Patron/Messages.t line 90. > got: '1100' > expected: '1101' > Looks like you failed 1 test of 12. >t/db_dependent/Koha/Patron/Messages.t .. Dubious, test returned 1 (wstat 256, 0x100) >Failed 1/12 subtests > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> >--- > t/db_dependent/Koha/Patron/Messages.t | 26 +++++++++++++++++++------- > 1 file changed, 19 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron/Messages.t b/t/db_dependent/Koha/Patron/Messages.t >index 3bd9767..1260185 100644 >--- a/t/db_dependent/Koha/Patron/Messages.t >+++ b/t/db_dependent/Koha/Patron/Messages.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 12; > > use C4::Context; > use C4::Log; >@@ -38,6 +38,7 @@ my $builder = t::lib::TestBuilder->new; > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower', value => { branchcode => $library->{branchcode} } } ); > my $patron_2 = $builder->build( { source => 'Borrower' } ); >+my $patron_3 = $builder->build( { source => 'Borrower' } ); > my $nb_of_logaction = get_nb_of_logactions(); > my $nb_of_messages = Koha::Patron::Messages->search->count; > >@@ -66,26 +67,37 @@ my $new_message_2 = Koha::Patron::Message->new( > message => 'my message 2', > } > )->store; >-is( get_nb_of_logactions(), $nb_of_logaction + 1, 'With BorrowersLog on, 1 new log should have been added when adding a new message' ); >+ >+my $new_message_3 = Koha::Patron::Message->new( >+ { borrowernumber => $patron->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ message_type => 'B', >+ message => 'my message 2', >+ manager_id => $patron_3->{borrowernumber}, >+ } >+)->store; >+is( get_nb_of_logactions(), $nb_of_logaction + 2, 'With BorrowersLog on, 2 new log should have been added when adding a new message' ); > > like( $new_message_1->message_id, qr|^\d+$|, 'Adding a new message should have set the message_id'); >-is( Koha::Patron::Messages->search->count, $nb_of_messages + 2, 'The 2 messages should have been added' ); >+is( Koha::Patron::Messages->search->count, $nb_of_messages + 3, 'The 3 messages should have been added' ); > > my $retrieved_message_1 = Koha::Patron::Messages->find( $new_message_1->message_id ); > is( $retrieved_message_1->message, $new_message_1->message, 'Find a message by id should return the correct message' ); > is( $retrieved_message_1->manager_id, undef, 'Manager id should not be filled in when it is not defined in userenv' ); > my $retrieved_message_2 = Koha::Patron::Messages->find( $new_message_2->message_id ); > is( $retrieved_message_2->manager_id, $patron_2->{borrowernumber}, 'Manager id should be filled in when it is defined in userenv' ); >+my $retrieved_message_3 = Koha::Patron::Messages->find( $new_message_3->message_id ); >+is( $retrieved_message_3->manager_id, $patron_3->{borrowernumber}, 'Manager id should be overwrite-able even if defined in userenv' ); > > t::lib::Mocks::mock_preference('BorrowersLog', 0); > $retrieved_message_1->delete; >-is( Koha::Patron::Messages->search->count, $nb_of_messages + 1, 'Delete should have deleted the message 1' ); >-is( get_nb_of_logactions(), $nb_of_logaction + 1, 'With BorrowersLog off, no new log should have been added when deleting a new message' ); >+is( Koha::Patron::Messages->search->count, $nb_of_messages + 2, 'Delete should have deleted the message 1' ); >+is( get_nb_of_logactions(), $nb_of_logaction + 2, 'With BorrowersLog off, no new log should have been added when deleting a new message' ); > > t::lib::Mocks::mock_preference('BorrowersLog', 1); > $new_message_2->delete; >-is( Koha::Patron::Messages->search->count, $nb_of_messages, 'Delete should have deleted the message 2' ); >-is( get_nb_of_logactions(), $nb_of_logaction + 2, 'With BorrowersLog on, 1 new log should have been added when deleting a new message' ); >+is( Koha::Patron::Messages->search->count, $nb_of_messages + 1, 'Delete should have deleted the message 2' ); >+is( get_nb_of_logactions(), $nb_of_logaction + 3, 'With BorrowersLog on, 1 new log should have been added when deleting a new message' ); > > $schema->storage->txn_rollback; > >-- >2.7.4
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 24016
:
95299
|
95300
|
95301
|
95302
|
95461
|
95462
|
96379
|
96380
|
96381
|
96761