Bugzilla – Attachment 51699 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 AddIssue
Bug-16534-Add-tests-for-AddIssue.patch (text/plain), 4.34 KB, created by
Jonathan Druart
on 2016-05-22 09:20:37 UTC
(
hide
)
Description:
Bug 16534: Add tests for AddIssue
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-05-22 09:20:37 UTC
Size:
4.34 KB
patch
obsolete
>From d44b9bed1fe6386c06cdc7c0e86cb54af6f373e0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 22 May 2016 10:03:11 +0100 >Subject: [PATCH] Bug 16534: Add tests for AddIssue > >--- > t/db_dependent/Circulation.t | 76 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 75 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 72436a0..f06e4d5 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 => 85; >+use Test::More tests => 86; > > BEGIN { > use_ok('C4::Circulation'); >@@ -998,6 +998,80 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); > }; > >+subtest 'AddIssue & AllowReturnToBranch' => sub { >+ plan tests => 9; >+ >+ 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 $ref_issue = 'Koha::Schema::Result::Issue'; # FIXME Should be Koha::Issue >+ my $issue = AddIssue( $patron_1, $item->{barcode} ); >+ >+ my ( $error, $question, $alerts ); >+ >+ # AllowReturnToBranch == homebranch >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); >+ ## Can be issued from homebranch >+ set_userenv($homebranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ ## Can be issued from holdinbranch >+ set_userenv($holdingbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ ## Can be issued from another branch >+ set_userenv($otherbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ >+ # AllowReturnToBranch == holdinbranch >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); >+ ## Cannot be issued from homebranch >+ set_userenv($homebranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); >+ ## Can be issued from holdingbranch >+ set_userenv($holdingbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ ## Cannot be issued from another branch >+ set_userenv($otherbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); >+ >+ # AllowReturnToBranch == homebranch >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); >+ ## Can be issued from homebranch >+ set_userenv($homebranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ ## Cannot be issued from holdinbranch >+ set_userenv($holdingbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); >+ ## Cannot be issued from another branch >+ set_userenv($otherbranch); >+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' ); >+ # 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}, '', '', ''); >-- >2.8.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 16534
:
51687
|
51697
|
51698
|
51699
|
51700
|
51706
|
51707
|
51708
|
51709
|
51710
|
52487
|
52488
|
52489
|
52490
|
52491
|
52492
|
52493