source: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfPrePointTest.php @ 22202

Revision 22202, 2.7 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

#1977 #1978 単体テストのファイルにコピーライトを追記、定数が邪魔をしてテストできない箇所をいったんコメントアウト

  • Property svn:keywords set to Id Rev Date
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4// テスト用にデフォルトの丸め方法を指定
5define('POINT_RULE', 1); // 四捨五入
6require_once($HOME . "/tests/class/Common_TestCase.php");
7/*
8 * This file is part of EC-CUBE
9 *
10 * Copyright(c) 2000-2012 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 */
36class SC_Utils_sfPrePointTest extends Common_TestCase {
37
38
39  protected function setUp() {
40    // parent::setUp();
41  }
42
43  protected function tearDown() {
44    // parent::tearDown();
45  }
46
47  /////////////////////////////////////////
48  public function testSfPrePoint_四捨五入の設定の場合_四捨五入された値が返る() {
49    $rule = 1; // 四捨五入
50
51    $this->expected = 10;
52    $this->actual = SC_Utils::sfPrePoint(100, 9.5, $rule);
53
54    $this->verify();
55  }
56
57  public function testSfPrePoint_切り捨ての設定の場合_切り捨てされた値が返る() {
58    $rule = 2; // 切り捨て
59
60    $this->expected = 9;
61    $this->actual = SC_Utils::sfPrePoint(100, 9.5, $rule);
62
63    $this->verify();
64  }
65
66  public function testSfPrePoint_切り上げの設定の場合_切り上げされた値が返る() {
67    $rule = 3; // 切り上げ
68
69    $this->expected = 10;
70    $this->actual = SC_Utils::sfPrePoint(100, 9.4, $rule);
71
72    $this->verify();
73  }
74
75  public function testSfPrePoint_存在しない選択肢の場合_切り上げされた値が返る() {
76    $rule = 4; // 存在しない選択肢
77
78    $this->expected = 10;
79    $this->actual = SC_Utils::sfPrePoint(100, 9.4, $rule);
80
81    $this->verify();
82  }
83
84  public function testSfPrePoint_丸め方法の指定がない場合_定数で指定された値が使われる() {
85    $this->expected = array(9, 9);
86    $this->actual = array(
87      SC_Utils::sfPrePoint(100, 9.4),
88      SC_Utils::sfPrePoint(100, 9.5)
89    );
90
91    $this->verify();
92  }
93
94  //////////////////////////////////////////
95
96}
97
Note: See TracBrowser for help on using the repository browser.