1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | // テスト用にデフォルトの丸め方法を指定 |
---|
5 | define('POINT_RULE', 1); // 四捨五入 |
---|
6 | require_once($HOME . "/tests/class/Common_TestCase.php"); |
---|
7 | /* |
---|
8 | * This file is part of EC-CUBE |
---|
9 | * |
---|
10 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
11 | * |
---|
12 | * http://www.lockon.co.jp/ |
---|
13 | * |
---|
14 | * This program is free software; you can redistribute it and/or |
---|
15 | * modify it under the terms of the GNU General Public License |
---|
16 | * as published by the Free Software Foundation; either version 2 |
---|
17 | * of the License, or (at your option) any later version. |
---|
18 | * |
---|
19 | * This program is distributed in the hope that it will be useful, |
---|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | * GNU General Public License for more details. |
---|
23 | * |
---|
24 | * You should have received a copy of the GNU General Public License |
---|
25 | * along with this program; if not, write to the Free Software |
---|
26 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | * SC_Utils::sfPrePoint()のテストクラス. |
---|
31 | * |
---|
32 | * |
---|
33 | * @author Hiroko Tamagawa |
---|
34 | * @version $Id$ |
---|
35 | */ |
---|
36 | class SC_Utils_sfPrePointTest extends Common_TestCase |
---|
37 | { |
---|
38 | |
---|
39 | |
---|
40 | protected function setUp() |
---|
41 | { |
---|
42 | // parent::setUp(); |
---|
43 | } |
---|
44 | |
---|
45 | protected function tearDown() |
---|
46 | { |
---|
47 | // parent::tearDown(); |
---|
48 | } |
---|
49 | |
---|
50 | ///////////////////////////////////////// |
---|
51 | public function testSfPrePoint_四捨五入の設定の場合_四捨五入された値が返る() |
---|
52 | { |
---|
53 | $rule = 1; // 四捨五入 |
---|
54 | |
---|
55 | $this->expected = 10; |
---|
56 | $this->actual = SC_Utils::sfPrePoint(100, 9.5, $rule); |
---|
57 | |
---|
58 | $this->verify(); |
---|
59 | } |
---|
60 | |
---|
61 | public function testSfPrePoint_切り捨ての設定の場合_切り捨てされた値が返る() |
---|
62 | { |
---|
63 | $rule = 2; // 切り捨て |
---|
64 | |
---|
65 | $this->expected = 9; |
---|
66 | $this->actual = SC_Utils::sfPrePoint(100, 9.5, $rule); |
---|
67 | |
---|
68 | $this->verify(); |
---|
69 | } |
---|
70 | |
---|
71 | public function testSfPrePoint_切り上げの設定の場合_切り上げされた値が返る() |
---|
72 | { |
---|
73 | $rule = 3; // 切り上げ |
---|
74 | |
---|
75 | $this->expected = 10; |
---|
76 | $this->actual = SC_Utils::sfPrePoint(100, 9.4, $rule); |
---|
77 | |
---|
78 | $this->verify(); |
---|
79 | } |
---|
80 | |
---|
81 | public function testSfPrePoint_存在しない選択肢の場合_切り上げされた値が返る() |
---|
82 | { |
---|
83 | $rule = 4; // 存在しない選択肢 |
---|
84 | |
---|
85 | $this->expected = 10; |
---|
86 | $this->actual = SC_Utils::sfPrePoint(100, 9.4, $rule); |
---|
87 | |
---|
88 | $this->verify(); |
---|
89 | } |
---|
90 | |
---|
91 | public function testSfPrePoint_丸め方法の指定がない場合_定数で指定された値が使われる() |
---|
92 | { |
---|
93 | $this->expected = array(9, 9); |
---|
94 | $this->actual = array( |
---|
95 | SC_Utils::sfPrePoint(100, 9.4), |
---|
96 | SC_Utils::sfPrePoint(100, 9.5) |
---|
97 | ); |
---|
98 | |
---|
99 | $this->verify(); |
---|
100 | } |
---|
101 | |
---|
102 | ////////////////////////////////////////// |
---|
103 | |
---|
104 | } |
---|
105 | |
---|