Browse Source
Adds the ability to generate a return claim from a Checkout object. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Lisette Scheer <lisetteslatah@gmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>remotes/origin/19.11.x
2 changed files with 150 additions and 2 deletions
@ -0,0 +1,96 @@ |
|||
#!/usr/bin/perl |
|||
|
|||
# This file is part of Koha. |
|||
# |
|||
# Koha is free software; you can redistribute it and/or modify it |
|||
# under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# Koha is distributed in the hope that it will be useful, but |
|||
# WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
|||
|
|||
use Modern::Perl; |
|||
|
|||
use Test::More tests => 1; |
|||
use Test::MockModule; |
|||
use Test::Warn; |
|||
|
|||
use t::lib::Mocks; |
|||
use t::lib::TestBuilder; |
|||
|
|||
use C4::Circulation; |
|||
|
|||
# Mock userenv, used by AddIssue |
|||
my $branch; |
|||
my $manager_id; |
|||
my $context = Test::MockModule->new('C4::Context'); |
|||
$context->mock( |
|||
'userenv', |
|||
sub { |
|||
return { |
|||
branch => $branch, |
|||
number => $manager_id, |
|||
firstname => "Adam", |
|||
surname => "Smaith" |
|||
}; |
|||
} |
|||
); |
|||
|
|||
my $schema = Koha::Database->schema; |
|||
$schema->storage->txn_begin; |
|||
|
|||
my $builder = t::lib::TestBuilder->new(); |
|||
Koha::IssuingRules->search->delete; |
|||
my $rule = Koha::IssuingRule->new( |
|||
{ |
|||
categorycode => '*', |
|||
itemtype => '*', |
|||
branchcode => '*', |
|||
issuelength => 1, |
|||
} |
|||
); |
|||
$rule->store(); |
|||
|
|||
$branch = $builder->build( { source => 'Branch' } )->{branchcode}; |
|||
|
|||
subtest 'Test Koha::Checkout::claim_returned' => sub { |
|||
plan tests => 6; |
|||
|
|||
t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue', 1 ); |
|||
my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); |
|||
my $item = $builder->build_object( |
|||
{ |
|||
class => 'Koha::Items', |
|||
value => { |
|||
biblionumber => $biblio->biblionumber, |
|||
notforloan => 0, |
|||
itemlost => 0, |
|||
withdrawn => 0, |
|||
} |
|||
} |
|||
); |
|||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|||
my $checkout = AddIssue( $patron->unblessed, $item->barcode ); |
|||
|
|||
my $claim = $checkout->claim_returned( |
|||
{ |
|||
created_by => $patron->id, |
|||
notes => "Test note", |
|||
} |
|||
); |
|||
|
|||
is( $claim->issue_id, $checkout->id, "Claim issue id matches" ); |
|||
is( $claim->itemnumber, $item->id, "Claim itemnumber matches" ); |
|||
is( $claim->borrowernumber, $patron->id, "Claim borrowernumber matches" ); |
|||
is( $claim->notes, "Test note", "Claim notes match" ); |
|||
is( $claim->created_by, $patron->id, "Claim created_by matches" ); |
|||
ok( $claim->created_on, "Claim created_on is set" ); |
|||
}; |
|||
|
|||
$schema->storage->txn_rollback; |
Loading…
Reference in new issue