Bugzilla – Attachment 113114 Details for
Bug 24603
Allow to cancel charges in patron accounting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24603: Simplify tests using TestBuilder
Bug-24603-Simplify-tests-using-TestBuilder.patch (text/plain), 4.18 KB, created by
Jonathan Druart
on 2020-11-05 13:41:05 UTC
(
hide
)
Description:
Bug 24603: Simplify tests using TestBuilder
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-11-05 13:41:05 UTC
Size:
4.18 KB
patch
obsolete
>From f0084490ed2df0865167ae9af9912381b759cf2e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 5 Nov 2020 14:40:29 +0100 >Subject: [PATCH] Bug 24603: Simplify tests using TestBuilder > >--- > t/db_dependent/Koha/Account/Line.t | 50 +++++++----------------------- > 1 file changed, 11 insertions(+), 39 deletions(-) > >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index c000a7439d..3110933196 100755 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -1084,45 +1084,17 @@ subtest "cancel() tests" => sub { > > $schema->storage->txn_begin; > >- # Create a borrower >- my $categorycode = >- $builder->build( { source => 'Category' } )->{categorycode}; >- my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >- >- my $borrower = Koha::Patron->new( >- { >- cardnumber => 'dariahall', >- surname => 'Hall', >- firstname => 'Daria', >- } >- ); >- $borrower->categorycode($categorycode); >- $borrower->branchcode($branchcode); >- $borrower->store; >- >- my $staff = Koha::Patron->new( >- { >- cardnumber => 'bobby', >- surname => 'Bloggs', >- firstname => 'Bobby', >- } >- ); >- $staff->categorycode($categorycode); >- $staff->branchcode($branchcode); >- $staff->store; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->branchcode } }); >+ my $staff = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->branchcode } }); > >- t::lib::Mocks::mock_userenv( >- { >- branchcode => $branchcode, >- borrowernumber => $borrower->borrowernumber >- } >- ); >+ t::lib::Mocks::mock_userenv({ patron => $patron }); > >- my $account = Koha::Account->new( { patron_id => $borrower->id } ); >+ my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); > > my $debit1 = Koha::Account::Line->new( > { >- borrowernumber => $borrower->borrowernumber, >+ borrowernumber => $patron->borrowernumber, > amount => 10, > amountoutstanding => 10, > interface => 'commandline', >@@ -1131,7 +1103,7 @@ subtest "cancel() tests" => sub { > )->store(); > my $debit2 = Koha::Account::Line->new( > { >- borrowernumber => $borrower->borrowernumber, >+ borrowernumber => $patron->borrowernumber, > amount => 20, > amountoutstanding => 20, > interface => 'commandline', >@@ -1154,7 +1126,7 @@ subtest "cancel() tests" => sub { > 15, 'Second fee has amount outstanding of 15' ); > throws_ok { > $credit->cancel( >- { staff_id => $staff->borrowernumber, branch => $branchcode } ); >+ { staff_id => $staff->borrowernumber, branch => $library->branchcode } ); > } > 'Koha::Exceptions::Account::IsNotDebit', > '->cancel() can only be used with debits'; >@@ -1165,20 +1137,20 @@ subtest "cancel() tests" => sub { > 'Koha::Exceptions::MissingParameter', > "->cancel() requires the `branch` parameter is passed"; > throws_ok { >- $debit1->reduce( { branch => $branchcode } ); >+ $debit1->reduce( { branch => $library->branchcode } ); > } > 'Koha::Exceptions::MissingParameter', > "->cancel() requires the `staff_id` parameter is passed"; > > throws_ok { > $debit2->cancel( >- { staff_id => $staff->borrowernumber, branch => $branchcode } ); >+ { staff_id => $staff->borrowernumber, branch => $library->branchcode } ); > } > 'Koha::Exceptions::Account', > '->cancel() can only be used with debits that have not been offset'; > > my $cancellation = $debit1->cancel( >- { staff_id => $staff->borrowernumber, branch => $branchcode } ); >+ { staff_id => $staff->borrowernumber, branch => $library->branchcode } ); > is( ref($cancellation), 'Koha::Account::Line', > 'Cancel returns an account line' ); > is( >-- >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 24603
:
98534
|
98551
|
102005
|
106772
|
111217
|
111218
|
111255
|
111256
|
111794
|
111795
|
111796
|
111797
|
111914
|
113048
|
113049
|
113050
|
113051
|
113052
|
113113
| 113114