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

Revision 22567, 3.7 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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
30    protected function setUp()
31    {
32        parent::setUp();
33        $this->objDate = new SC_Date_Ex();
34    }
35
36    protected function tearDown()
37    {
38        parent::tearDown();
39    }
40
41    /////////////////////////////////////////
42 
43    public function testGetYear_要素の数が4の配列を返す()
44    {
45        $this->expected = 4;
46        $this->actual = count($this->objDate->getYear());
47
48        $this->verify("配列の長さ");
49    }
50   
51    public function testGetYear_最小値が今年の配列を返す()
52    {
53        $this->expected = DATE('Y');
54        $this->actual = min($this->objDate->getYear());
55
56        $this->verify("最小値;今年");
57    }
58   
59    public function testGetYear_最低値が引数の年の配列を返す()
60    {
61        $this->expected = '2007';
62        $this->actual = min($this->objDate->getYear('2007'));
63
64        $this->verify("引数が最低値");
65    }
66   
67    public function testGetYear_最低値がメンバー変数の年の配列を返す()
68    {
69        $this->expected = '2004';
70        $this->objDate->setStartYear('2004');
71        $this->actual = min($this->objDate->getYear());
72
73        $this->verify("メンバー変数が最低値");
74    }
75   
76    public function testGetYear_最大値が3年後の配列を返す()
77    {
78        $this->expected = DATE('Y')+3;
79        $this->actual = max($this->objDate->getYear());
80
81        $this->verify("最大値;3年後");
82    }
83   
84    public function testGetYear_最大値がメンバ変数の配列を返す()
85    {
86        $this->expected = '2020';
87        $this->objDate->setEndYear('2020');
88        $this->actual = max($this->objDate->getYear());
89
90        $this->verify("メンバー変数が最大値");
91    }
92   
93    public function testGetYear_デフォルト値が含まれる配列を返す()
94    {
95        $result = in_array('----', $this->objDate->getYear(DATE('Y'), TRUE));
96        $this->assertTrue($result, "デフォルト値");
97    }
98   
99    public function testGetYear_デフォルト値の引数に年を指定した配列を返す()
100    {
101        $year = date('Y');
102        $this->expected = array( $year => $year, $year+1 => $year+1
103                               , '----' => '----'
104                               , $year+2 => $year+2, $year+3 => $year+3);
105        $this->actual = $this->objDate->getYear(DATE('Y'), $year+1);
106        $this->assertSame($this->expected, $this->actual, "デフォルト値");
107    }
108
109    public function testGetYear_引数に指定したキーがデフォルト値となる配列を返す()
110    {
111        $this->expected = 'default';
112        $return = $this->objDate->getYear(DATE('Y'), TRUE, 'default');
113        $this->actual = array_search('----', $return);
114        $this->verify("デフォルトキー");
115    }
116
117}
118
Note: See TracBrowser for help on using the repository browser.