Bugzilla – Attachment 82751 Details for
Bug 21909
Koha::Account::outstanding_* methods should preserve call context
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21909: Unit tests
Bug-21909-Unit-tests.patch (text/plain), 4.02 KB, created by
Martin Renvoize (ashimema)
on 2018-11-29 15:37:51 UTC
(
hide
)
Description:
Bug 21909: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-11-29 15:37:51 UTC
Size:
4.02 KB
patch
obsolete
>From 25e59f087ee5d85500d4572e16bb91d3ad9eea2a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 29 Nov 2018 12:08:03 -0300 >Subject: [PATCH] Bug 21909: Unit tests > >This patch introduces regression tests for the behaviour to be >introduced. Both outstanding_credits and outstanding_debits methods >should return a Koha::Account::Lines object in scalar context, and a >list of Koha::Account::Line objects in list context. > >To test: >- Apply this patch >- Run > $ kshell > k$ prove t/db_dependent/Koha/Account.t >=> FAIL: The current behaviour doesn't match the described > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Account.t | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index ff400c7552..cf81888bbd 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -33,11 +33,12 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'outstanding_debits() tests' => sub { > >- plan tests => 12; >+ plan tests => 21; > > $schema->storage->txn_begin; > >- my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $account = $patron->account; > > my @generated_lines; > push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store; >@@ -45,15 +46,18 @@ subtest 'outstanding_debits() tests' => sub { > push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store; > push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store; > >- my $account = $patron->account; >- my $lines = $account->outstanding_debits(); >+ my $lines = $account->outstanding_debits(); >+ my @lines_arr = $account->outstanding_debits(); > >+ is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_debits returns a Koha::Account::Lines object' ); > is( $lines->total_outstanding, 10, 'Outstandig debits total is correctly calculated' ); > > my $i = 0; > foreach my $line ( @{ $lines->as_list } ) { > my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); > is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); >+ is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); >+ is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' ); > $i++; > } > >@@ -85,7 +89,7 @@ subtest 'outstanding_debits() tests' => sub { > > subtest 'outstanding_credits() tests' => sub { > >- plan tests => 7; >+ plan tests => 16; > > $schema->storage->txn_begin; > >@@ -98,14 +102,18 @@ subtest 'outstanding_credits() tests' => sub { > push @generated_lines, $account->add_credit({ amount => 3 }); > push @generated_lines, $account->add_credit({ amount => 4 }); > >- my $lines = $account->outstanding_credits(); >+ my $lines = $account->outstanding_credits(); >+ my @lines_arr = $account->outstanding_credits(); > >+ is( ref($lines), 'Koha::Account::Lines', 'Called in scalar context, outstanding_credits returns a Koha::Account::Lines object' ); > is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' ); > > my $i = 0; > foreach my $line ( @{ $lines->as_list } ) { > my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); > is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); >+ is_deeply( $lines_arr[$i]->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); >+ is( ref($lines_arr[$i]), 'Koha::Account::Line', 'outstanding_debits returns a list of Koha::Account::Line objects in list context' ); > $i++; > } > >-- >2.19.2
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 21909
:
82746
|
82747
|
82748
|
82751
|
82752
|
82753
|
82799
|
82800
|
82801
|
83511
|
83512
|
83513