Bugzilla – Attachment 68313 Details for
Bug 19487
Internal server error when writing off lost fine for item not checked out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19487: (QA follow-up) More changes to MarkIssueReturned.t
Bug-19487-QA-follow-up-More-changes-to-MarkIssueRe.patch (text/plain), 4.63 KB, created by
Marcel de Rooy
on 2017-10-20 07:56:39 UTC
(
hide
)
Description:
Bug 19487: (QA follow-up) More changes to MarkIssueReturned.t
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-10-20 07:56:39 UTC
Size:
4.63 KB
patch
obsolete
>From 17cbae8958d95d3dd3f16a52d94914b8510b419d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 20 Oct 2017 09:03:35 +0200 >Subject: [PATCH] Bug 19487: (QA follow-up) More changes to MarkIssueReturned.t >Content-Type: text/plain; charset=utf-8 > >$dbh is not used >$categorycode is no longer used >%item_branch_infos not used >$borrowernumber is obsoleted by using $patron >No real need for $anonymous_borrowernumber >No AddMember calls, removing unneeded modules > >Adding a test that calls MarkIssueReturned on an item already returned. > >Test plan: >[1] Without the patch changing MarkIssueReturned, this test fails (3 of 6). >[2] With the patch, the test should pass. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Circulation/MarkIssueReturned.t | 42 ++++++++++++-------------- > 1 file changed, 19 insertions(+), 23 deletions(-) > >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index 69b1b72..d2cf238 100644 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -17,19 +17,17 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 6; > use Test::Warn; > > use t::lib::Mocks; > use t::lib::TestBuilder; > > use C4::Circulation; >-use C4::Members; >-use Koha::Library; >+use C4::Context; >+use Koha::Database; > > my $schema = Koha::Database->schema; >-my $dbh = C4::Context->dbh; >- > $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new; >@@ -37,19 +35,12 @@ my $builder = t::lib::TestBuilder->new; > t::lib::Mocks::mock_preference('AnonymousPatron', ''); > > my $library = $builder->build({ source => 'Branch' }); >-my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; > > C4::Context->_new_userenv('xxx'); > C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); > >-my %item_branch_infos = ( >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >-); >- >-my $borrowernumber = AddMember( categorycode => $categorycode, branchcode => $library->{branchcode} ); > my $patron_category = $builder->build({ source => 'Category', value => { categorycode => 'NOT_X', category_type => 'P', enrolmentfee => 0 } }); >- my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >+my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); > > my $biblioitem = $builder->build( { source => 'Biblioitem' } ); > my $item = $builder->build( >@@ -65,17 +56,22 @@ my $item = $builder->build( > } > } > ); >-C4::Circulation::AddIssue( $patron, $item->{barcode} ); >+my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode} ); > >-eval { C4::Circulation::MarkIssueReturned( $borrowernumber, $item->{itemnumber}, 'dropbox_branch', 'returndate', 2 ) }; >-like ( $@, qr<Fatal error: the patron \(\d+\) .* AnonymousPatron>, ); >+eval { C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, $item->{itemnumber}, 'dropbox_branch', 'returndate', 2 ) }; >+like ( $@, qr<Fatal error: the patron \(\d+\) .* AnonymousPatron>, 'Fatal error on anonymization' ); > >-my $anonymous_borrowernumber = AddMember( categorycode => $categorycode, branchcode => $library->{branchcode} ); >-t::lib::Mocks::mock_preference('AnonymousPatron', $anonymous_borrowernumber); >-# The next call will raise an error, because data are not correctly set >-$dbh->{PrintError} = 0; >-eval { C4::Circulation::MarkIssueReturned( $borrowernumber, 'itemnumber', 'dropbox_branch', 'returndate', 2 ) }; >-unlike ( $@, qr<Fatal error: the patron \(\d+\) .* AnonymousPatron>, ); >+# The next call will return undef for invalid item number >+my $issue_id; >+eval { $issue_id = C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, 'invalid_itemnumber', 'dropbox_branch', 'returndate', 0 ) }; >+is( $@, '', 'No die triggered by invalid itemnumber' ); >+is( $issue_id, undef, 'No issue_id returned' ); > >-$schema->storage->txn_rollback; >+# In the next call we return the item and try it another time >+eval { $issue_id = C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, $item->{itemnumber}, undef, undef, 0 ) }; >+is( $issue_id, $issue->issue_id, "Item has been returned (issue $issue_id)" ); >+eval { $issue_id = C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, $item->{itemnumber}, undef, undef, 0 ) }; >+is( $@, '', 'No crash on returning item twice' ); >+is( $issue_id, undef, 'Cannot return an item twice' ); > >+$schema->storage->txn_rollback; >-- >2.1.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 19487
:
68275
|
68293
|
68294
|
68312
|
68313
|
68314
|
68330