DateTest4GenYear::test_GenYear_Args2()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 15

Duplication

Lines 19
Ratio 100 %

Importance

Changes 4
Bugs 2 Features 1
Metric Value
c 4
b 2
f 1
dl 19
loc 19
rs 9.4285
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
/**
3
 * DateTest4GenYear
4
 *
5
 * Date::GenYear用テストケース
6
 *
7
 * @package           risoluto
8
 * @author            Risoluto Developers
9
 * @license           http://opensource.org/licenses/bsd-license.php new BSD license
10
 * @copyright     (C) 2008-2015 Risoluto Developers / All Rights Reserved.
11
 */
12
13
//------------------------------------------------------//
14
// 名前空間の定義
15
//------------------------------------------------------//
16
namespace Risoluto;
17
18
//------------------------------------------------------//
19
// テストクラス定義
20
//------------------------------------------------------//
21
class DateTest4GenYear extends \PHPUnit_Framework_TestCase
22
{
23
    //------------------------------------------------------//
24
    // テストメソッド定義
25
    //------------------------------------------------------//
26
    /**
27
     * setUp()
28
     *
29
     * テストに必要な準備を実施
30
     */
31
    protected function setUp()
32
    {
33
    }
34
35
    /**
36
     * test_GenYear_NoArgs()
37
     *
38
     * GenYear()の挙動をテストする(引数なし)
39
     */
40
    public function test_GenYear_NoArgs()
41
    {
42
        $tmpYear = date( 'Y' ) - 5;
43
        $want = [
44
            $tmpYear + 0 => $tmpYear + 0,
45
            $tmpYear + 1 => $tmpYear + 1,
46
            $tmpYear + 2 => $tmpYear + 2,
47
            $tmpYear + 3 => $tmpYear + 3,
48
            $tmpYear + 4 => $tmpYear + 4,
49
            $tmpYear + 5 => $tmpYear + 5,
50
            $tmpYear + 6 => $tmpYear + 6,
51
            $tmpYear + 7 => $tmpYear + 7,
52
            $tmpYear + 8 => $tmpYear + 8,
53
            $tmpYear + 9 => $tmpYear + 9,
54
        ];
55
56
        $this->assertEquals( Date::genYear(), $want );
57
    }
58
59
    /**
60
     * test_GenYear_Args1()
61
     *
62
     * GenYear()の挙動をテストする(引数1つ)
63
     */
64 View Code Duplication
    public function test_GenYear_Args1()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
        $tmpYear = date( 'Y' ) - 5;
67
        $want = [
68
            '' => '',
69
            $tmpYear + 0 => $tmpYear + 0,
70
            $tmpYear + 1 => $tmpYear + 1,
71
            $tmpYear + 2 => $tmpYear + 2,
72
            $tmpYear + 3 => $tmpYear + 3,
73
            $tmpYear + 4 => $tmpYear + 4,
74
            $tmpYear + 5 => $tmpYear + 5,
75
            $tmpYear + 6 => $tmpYear + 6,
76
            $tmpYear + 7 => $tmpYear + 7,
77
            $tmpYear + 8 => $tmpYear + 8,
78
            $tmpYear + 9 => $tmpYear + 9,
79
        ];
80
81
        $this->assertEquals( Date::genYear( true ), $want );
82
    }
83
84
    /**
85
     * test_GenYear_Args2()
86
     *
87
     * GenYear()の挙動をテストする(引数2つ)
88
     */
89 View Code Duplication
    public function test_GenYear_Args2()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        $tmpYear = date( 'Y' ) - 5;
92
        $want = [
93
            '----' => '',
94
            $tmpYear + 0 => $tmpYear + 0,
95
            $tmpYear + 1 => $tmpYear + 1,
96
            $tmpYear + 2 => $tmpYear + 2,
97
            $tmpYear + 3 => $tmpYear + 3,
98
            $tmpYear + 4 => $tmpYear + 4,
99
            $tmpYear + 5 => $tmpYear + 5,
100
            $tmpYear + 6 => $tmpYear + 6,
101
            $tmpYear + 7 => $tmpYear + 7,
102
            $tmpYear + 8 => $tmpYear + 8,
103
            $tmpYear + 9 => $tmpYear + 9,
104
        ];
105
106
        $this->assertEquals( Date::genYear( true, '----' ), $want );
107
    }
108
109
110
    /**
111
     * test_GenYear_Args4()
112
     *
113
     * GenYear()の挙動をテストする(引数4つ)
114
     */
115
    public function test_GenYear_Args4()
116
    {
117
        $want = [
118
            '----' => '----',
119
            2000 => '2000',
120
            2001 => '2001',
121
            2002 => '2002',
122
            2003 => '2003',
123
            2004 => '2004',
124
            2005 => '2005',
125
            2006 => '2006',
126
            2007 => '2007',
127
            2008 => '2008',
128
            2009 => '2009',
129
        ];
130
131
        $this->assertEquals( Date::genYear( true, '----', '----', 2000 ), $want );
132
    }
133
134
    /**
135
     * test_GenYear_Args5()
136
     *
137
     * GenYear()の挙動をテストする(引数5つ)
138
     */
139
    public function test_GenYear_Args5()
140
    {
141
        $want = [
142
            '----' => '----',
143
            2000 => '2000(平成12年)',
144
            2001 => '2001(平成13年)',
145
        ];
146
147
        $this->assertEquals( Date::genYear( true, '----', '----', 2000, 2, 2 ), $want );
148
    }
149
}