Bugzilla – Attachment 52487 Details for
Bug 16534
Error when checking out already checked out item (depending on AllowReturnToBranch)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16534: Add tests for CanBookBeIssued & AllowReturnToBranch
Bug-16534-Add-tests-for-CanBookBeIssued--AllowRetu.patch (text/plain), 5.45 KB, created by
Kyle M Hall (khall)
on 2016-06-17 16:30:44 UTC
(
hide
)
Description:
Bug 16534: Add tests for CanBookBeIssued & AllowReturnToBranch
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-17 16:30:44 UTC
Size:
5.45 KB
patch
obsolete
>From 84c274f5b0e1f51f0d518cf9cf653f5de9c8174f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 22 May 2016 10:02:44 +0100 >Subject: [PATCH] Bug 16534: Add tests for CanBookBeIssued & > AllowReturnToBranch >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 97 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 96 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index cfee3e2..72436a0 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -30,7 +30,7 @@ use Koha::Database; > > use t::lib::TestBuilder; > >-use Test::More tests => 84; >+use Test::More tests => 85; > > BEGIN { > use_ok('C4::Circulation'); >@@ -908,4 +908,99 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); > } > >+subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { >+ plan tests => 23; >+ >+ my $homebranch = $builder->build( { source => 'Branch' } ); >+ my $holdingbranch = $builder->build( { source => 'Branch' } ); >+ my $otherbranch = $builder->build( { source => 'Branch' } ); >+ my $patron_1 = $builder->build( { source => 'Borrower' } ); >+ my $patron_2 = $builder->build( { source => 'Borrower' } ); >+ >+ my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >+ my $item = $builder->build( >+ { source => 'Item', >+ value => { >+ homebranch => $homebranch->{branchcode}, >+ holdingbranch => $holdingbranch->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem->{biblionumber} >+ } >+ } >+ ); >+ >+ set_userenv($holdingbranch); >+ >+ my $issue = AddIssue( $patron_1, $item->{barcode} ); >+ is( ref($issue), 'Koha::Schema::Result::Issue' ); # FIXME Should be Koha::Issue >+ >+ my ( $error, $question, $alerts ); >+ >+ # AllowReturnToBranch == anywhere >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); >+ ## Can be issued from homebranch >+ set_userenv($homebranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$error) + keys(%$alerts), 0 ); >+ is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); >+ ## Can be issued from holdingbranch >+ set_userenv($holdingbranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$error) + keys(%$alerts), 0 ); >+ is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); >+ ## Can be issued from another branch >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$error) + keys(%$alerts), 0 ); >+ is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); >+ >+ # AllowReturnToBranch == holdingbranch >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); >+ ## Cannot be issued from homebranch >+ set_userenv($homebranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$question) + keys(%$alerts), 0 ); >+ is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); >+ is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); >+ ## Can be issued from holdinbranch >+ set_userenv($holdingbranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$error) + keys(%$alerts), 0 ); >+ is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); >+ ## Cannot be issued from another branch >+ set_userenv($otherbranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$question) + keys(%$alerts), 0 ); >+ is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); >+ is( $error->{branch_to_return}, $holdingbranch->{branchcode} ); >+ >+ # AllowReturnToBranch == homebranch >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); >+ ## Can be issued from holdinbranch >+ set_userenv($homebranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$error) + keys(%$alerts), 0 ); >+ is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); >+ ## Cannot be issued from holdinbranch >+ set_userenv($holdingbranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$question) + keys(%$alerts), 0 ); >+ is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); >+ is( $error->{branch_to_return}, $homebranch->{branchcode} ); >+ ## Cannot be issued from holdinbranch >+ set_userenv($otherbranch); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ is( keys(%$question) + keys(%$alerts), 0 ); >+ is( exists $error->{RETURN_IMPOSSIBLE}, 1 ); >+ is( $error->{branch_to_return}, $homebranch->{branchcode} ); >+ >+ # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); >+}; >+ >+sub set_userenv { >+ my ( $library ) = @_; >+ C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >+} >+ > 1; >-- >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 16534
:
51687
|
51697
|
51698
|
51699
|
51700
|
51706
|
51707
|
51708
|
51709
|
51710
|
52487
|
52488
|
52489
|
52490
|
52491
|
52492
|
52493