Bugzilla – Attachment 76991 Details for
Bug 18736
Problems in order calculations (rounding errors)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18736: (follow-up) Unit tests
Bug-18736-follow-up-Unit-tests.patch (text/plain), 3.51 KB, created by
Nick Clemens (kidclamp)
on 2018-07-16 11:45:04 UTC
(
hide
)
Description:
Bug 18736: (follow-up) Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-07-16 11:45:04 UTC
Size:
3.51 KB
patch
obsolete
>From 78f0d244d3aabbf23ed4bf2356cfffe5192bbb12 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 18 Apr 2018 14:35:48 +0000 >Subject: [PATCH] Bug 18736: (follow-up) Unit tests > >Test coverage for new C4::Acquisition functions. > >prove t/Acquisition.t >--- > t/Acquisition.t | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > create mode 100644 t/Acquisition.t > >diff --git a/t/Acquisition.t b/t/Acquisition.t >new file mode 100644 >index 0000000..8bf0c3d >--- /dev/null >+++ b/t/Acquisition.t >@@ -0,0 +1,69 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright (C) 2018 Mark Tompsett >+# >+# 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 => 3; >+use t::lib::Mocks; >+ >+use_ok( 'C4::Acquisition' ); >+ >+subtest 'Tests for _get_rounding_sql' => sub { >+ >+ plan tests => 2; >+ >+ my $value = '3.141592'; >+ >+ t::lib::Mocks::mock_preference( 'OrderPriceRounding', q{} ); >+ my $no_rounding_result = C4::Acquisition::_get_rounding_sql($value); >+ t::lib::Mocks::mock_preference( 'OrderPriceRounding', q{nearest_cent} ); >+ my $rounding_result = C4::Acquisition::_get_rounding_sql($value); >+ >+ ok( $no_rounding_result eq $value, "Value ($value) not to be rounded" ); >+ ok( $rounding_result =~ /CAST/, "Value ($value) will be rounded" ); >+ >+}; >+ >+subtest 'Test for get_rounded_price' => sub { >+ >+ plan tests => 6; >+ >+ my $exact_price = 3.14; >+ my $up_price = 3.145592; >+ my $down_price = 3.141592; >+ my $round_up_price = sprintf( '%0.2f', $up_price ); >+ my $round_down_price = sprintf( '%0.2f', $down_price ); >+ >+ t::lib::Mocks::mock_preference( 'OrderPriceRounding', q{} ); >+ my $not_rounded_result1 = C4::Acquisition::get_rounded_price($exact_price); >+ my $not_rounded_result2 = C4::Acquisition::get_rounded_price($up_price); >+ my $not_rounded_result3 = C4::Acquisition::get_rounded_price($down_price); >+ t::lib::Mocks::mock_preference( 'OrderPriceRounding', q{nearest_cent} ); >+ my $rounded_result1 = C4::Acquisition::get_rounded_price($exact_price); >+ my $rounded_result2 = C4::Acquisition::get_rounded_price($up_price); >+ my $rounded_result3 = C4::Acquisition::get_rounded_price($down_price); >+ >+ is( $not_rounded_result1, $exact_price, "Price ($exact_price) was correctly not rounded ($not_rounded_result1)" ); >+ is( $not_rounded_result2, $up_price, "Price ($up_price) was correctly not rounded ($not_rounded_result2)" ); >+ is( $not_rounded_result3, $down_price, "Price ($down_price) was correctly not rounded ($not_rounded_result3)" ); >+ is( $rounded_result1, $exact_price, "Price ($exact_price) was correctly rounded ($rounded_result1)" ); >+ is( $rounded_result2, $round_up_price, "Price ($up_price) was correctly rounded ($rounded_result2)" ); >+ is( $rounded_result3, $round_down_price, "Price ($down_price) was correctly rounded ($rounded_result3)" ); >+ >+}; >+ >-- >2.1.4
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 18736
:
64061
|
64065
|
70187
|
70188
|
70189
|
70768
|
71062
|
71063
|
71627
|
71628
|
71629
|
71630
|
71631
|
71632
|
74335
|
74336
|
74337
|
74338
|
74339
|
74340
|
74341
|
74342
|
74370
|
74371
|
74374
|
74397
|
74398
|
74422
|
74427
|
74438
|
76979
|
76980
|
76981
|
76982
|
76983
|
76984
|
76985
|
76986
|
76987
|
76988
|
76989
|
76990
|
76991
|
77614
|
77615
|
77616
|
77617
|
77618
|
78101
|
78120
|
78981
|
78982
|
78983
|
78984
|
78985
|
78986
|
78987
|
78988
|
79087
|
79088
|
79089
|
79090
|
79091
|
79092
|
79093
|
79094
|
79098
|
79099
|
79100
|
79101
|
79102
|
79103
|
79104
|
79105
|
79187
|
79223
|
79562
|
79563
|
82967
|
82968
|
82969
|
82970
|
82971
|
82972
|
82973
|
82974
|
82975
|
82976
|
82977
|
83212
|
83213
|
83214
|
83973
|
83974
|
83975
|
83976
|
83977
|
83978
|
83979
|
83980
|
83981
|
83982
|
83983
|
83984
|
83985
|
86646
|
86647
|
86648
|
86649
|
86650
|
86651
|
86652
|
86653
|
86654
|
86655
|
86656
|
86657
|
86658