source: branches/version-2_12-dev/tests/class/SC_Date/SC_Date_getYearTest.php @ 22796

Revision 22796, 3.7 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24$HOME = realpath(dirname(__FILE__)) . "/../../..";
25require_once($HOME . "/tests/class/Common_TestCase.php");
26
27class SC_Date_getYearTest extends Common_TestCase {
28
29    protected function setUp() {
30        parent::setUp();
31        $this->objDate = new SC_Date_Ex();
32    }
33
34    protected function tearDown() {
35        parent::tearDown();
36    }
37
38    /////////////////////////////////////////
39 
40    public function testGetYear_要素の数が4の配列を返す() {
41        $this->expected = 4;
42        $this->actual = count($this->objDate->getYear());
43
44        $this->verify("配列の長さ");
45    }
46   
47    public function testGetYear_最小値が今年の配列を返す() {
48        $this->expected = DATE('Y');
49        $this->actual = min($this->objDate->getYear());
50
51        $this->verify("最小値;今年");
52    }
53   
54    public function testGetYear_最低値が引数の年の配列を返す() {
55        $this->expected = '2007';
56        $this->actual = min($this->objDate->getYear('2007'));
57
58        $this->verify("引数が最低値");
59    }
60   
61    public function testGetYear_最低値がメンバー変数の年の配列を返す() {
62        $this->expected = '2004';
63        $this->objDate->setStartYear('2004');
64        $this->actual = min($this->objDate->getYear());
65
66        $this->verify("メンバー変数が最低値");
67    }
68   
69    public function testGetYear_最大値が3年後の配列を返す() {
70        $this->expected = DATE('Y')+3;
71        $this->actual = max($this->objDate->getYear());
72
73        $this->verify("最大値;3年後");
74    }
75   
76    public function testGetYear_最大値がメンバ変数の配列を返す() {
77        $this->expected = '2020';
78        $this->objDate->setEndYear('2020');
79        $this->actual = max($this->objDate->getYear());
80
81        $this->verify("メンバー変数が最大値");
82    }
83   
84    public function testGetYear_デフォルト値が含まれる配列を返す() {
85        $result = in_array('----', $this->objDate->getYear(DATE('Y'), TRUE));
86        $this->assertTrue($result, "デフォルト値");
87    }
88   
89    public function testGetYear_デフォルト値の引数に年を指定した配列を返す() {
90        $year = date('Y');
91        $this->expected = array( $year => $year, $year+1 => $year+1
92                               , '----' => '----'
93                               , $year+2 => $year+2, $year+3 => $year+3);
94        $this->actual = $this->objDate->getYear(DATE('Y'), $year+1);
95        $this->assertSame($this->expected, $this->actual, "デフォルト値");
96    }
97
98    public function testGetYear_引数に指定したキーがデフォルト値となる配列を返す() {
99        $this->expected = 'default';
100        $return = $this->objDate->getYear(DATE('Y'), TRUE, 'default');
101        $this->actual = array_search('----', $return);
102        $this->verify("デフォルトキー");
103    }
104
105}
106
Note: See TracBrowser for help on using the repository browser.