Bugzilla – Attachment 182127 Details for
Bug 39845
Add Koha::Acquisition::Orders->unreceived_totals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39845: Unit tests
Bug-39845-Unit-tests.patch (text/plain), 2.30 KB, created by
David Nind
on 2025-05-08 22:00:53 UTC
(
hide
)
Description:
Bug 39845: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-05-08 22:00:53 UTC
Size:
2.30 KB
patch
obsolete
>From 928129ee8c466f38dc2304b586378e877b8e1ef3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 6 May 2025 15:46:36 -0300 >Subject: [PATCH] Bug 39845: Unit tests > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Acquisition/Orders.t | 52 +++++++++++++++++++++++- > 1 file changed, 51 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Acquisition/Orders.t b/t/db_dependent/Koha/Acquisition/Orders.t >index 288e9ee646..b05d995482 100755 >--- a/t/db_dependent/Koha/Acquisition/Orders.t >+++ b/t/db_dependent/Koha/Acquisition/Orders.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -213,3 +213,53 @@ subtest 'filter_by_obsolete and cancel' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'unreceived_totals() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $empty_resultset = Koha::Acquisition::Orders->search->empty(); >+ >+ my $result = $empty_resultset->unreceived_totals(); >+ is( $result->{items_count}, 0, 'Zero unreceived items' ); >+ is( $result->{total_replacement_price}, 0, 'Zero cost for 0 items' ); >+ >+ my $rrp = 2.31; >+ >+ my $order_1 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { quantity => 10, quantityreceived => 5, rrp => $rrp } >+ } >+ ); >+ my $order_2 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { quantity => 10, quantityreceived => 4, rrp => $rrp } >+ } >+ ); >+ my $order_3 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { quantity => 10, quantityreceived => 3, rrp => $rrp } >+ } >+ ); >+ >+ my $rs = Koha::Acquisition::Orders->search( >+ { >+ ordernumber => [ >+ $order_1->id, >+ $order_2->id, >+ $order_3->id, >+ ] >+ } >+ ); >+ >+ $result = $rs->unreceived_totals(); >+ is( $result->{items_count}, 18, '18 unreceived items' ); >+ is( $result->{total_replacement_price}, 18 * $rrp, 'rrp * 18' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.5
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 39845
:
181992
|
181993
| 182127 |
182128