Bugzilla – Attachment 83544 Details for
Bug 22049
MarkIssueReturned should rely on returndate only
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22049: Add tests
Bug-22049-Add-tests.patch (text/plain), 4.13 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-12-28 18:35:34 UTC
(
hide
)
Description:
Bug 22049: Add tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-12-28 18:35:34 UTC
Size:
4.13 KB
patch
obsolete
>From 8ea7e20017e3754365567002b93a3d0ca64ce1f4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 28 Dec 2018 15:23:38 -0300 >Subject: [PATCH] Bug 22049: Add tests > >The current tests only check failure use cases. As we are changing the >way we store data, some tests are needed. > >To test: >- Apply this patchset >- Run: > $ kshell > k$ prove t/db_dependent/Circulation/MarkIssueReturned.t >=> SUCCESS: Tests pass! >--- > .../Circulation/MarkIssueReturned.t | 36 +++++++++++++------ > 1 file changed, 26 insertions(+), 10 deletions(-) > >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index 5538e1ba99..1915a9582b 100644 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 7; >+use Test::Exception; > use Test::Warn; > > use t::lib::Mocks; >@@ -27,27 +28,28 @@ use C4::Circulation; > use C4::Context; > use Koha::Checkouts; > use Koha::Database; >+use Koha::Old::Checkouts; > use Koha::Patrons; > > my $schema = Koha::Database->schema; >-$schema->storage->txn_begin; >- > my $builder = t::lib::TestBuilder->new; > >-my $library = $builder->build({ source => 'Branch' }); >+$schema->storage->txn_begin; >+ >+my $library = $builder->build_object({ class => 'Koha::Libraries' }); > >-t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); >+t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); > >-my $patron_category = $builder->build({ source => 'Category', value => { category_type => 'P', enrolmentfee => 0 } }); >-my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >+my $category = $builder->build({ source => 'Category', value => { category_type => 'P', enrolmentfee => 0 } }); >+my $patron = $builder->build({ source => 'Borrower', value => { branchcode => $library->branchcode, categorycode => $category->{categorycode} } } ); > > my $biblioitem = $builder->build( { source => 'Biblioitem' } ); > my $item = $builder->build( > { > source => 'Item', > value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >+ homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, > notforloan => 0, > itemlost => 0, > withdrawn => 0, >@@ -65,13 +67,27 @@ subtest 'anonymous patron' => sub { > like ( $@, qr<Fatal error: the patron \(\d+\) .* AnonymousPatron>, 'AnonymousPatron is not set - Fatal error on anonymization' ); > Koha::Checkouts->find( $issue->issue_id )->delete; > >- my $anonymous_borrowernumber = Koha::Patron->new({categorycode => $patron_category->{categorycode}, branchcode => $library->{branchcode} })->store->borrowernumber; >+ my $anonymous_borrowernumber = Koha::Patron->new({categorycode => $category->{categorycode}, branchcode => $library->branchcode })->store->borrowernumber; > t::lib::Mocks::mock_preference('AnonymousPatron', $anonymous_borrowernumber); > $issue = C4::Circulation::AddIssue( $patron, $item->{barcode} ); > eval { C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, $item->{itemnumber}, undef, 2 ) }; > is ( $@, q||, 'AnonymousPatron is set correctly - no error expected'); > }; > >+subtest 'Manually pass a return date' => sub { >+ >+ plan tests => 2; >+ >+ my $issue = C4::Circulation::AddIssue( $patron, $item->{barcode} ); >+ my $issue_id; >+ >+ eval { $issue_id = C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, $item->{itemnumber}, '2018-12-25', 0 ) }; >+ is( $issue_id, $issue->issue_id, "Item has been returned" ); >+ my $old_checkout = Koha::Old::Checkouts->find( $issue_id ); >+ is( $old_checkout->returndate, '2018-12-25 00:00:00', 'Manually passed date stored correctly' ); >+ >+}; >+ > my ( $issue_id, $issue ); > # The next call will return undef for invalid item number > eval { $issue_id = C4::Circulation::MarkIssueReturned( $patron->{borrowernumber}, 'invalid_itemnumber', undef, 0 ) }; >-- >2.20.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 22049
:
83542
|
83543
|
83544
|
83548
|
83549
|
83625
|
83626
|
83627
|
83654
|
83655
|
83656
|
83727
|
83728
|
83729
|
83730
|
85498