Completed
Push — develop ( d19f73...aa97bb )
by
unknown
08:38
created

DateTest::providerDateTimeExcelToTimestamp1900()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace PhpSpreadsheet\Tests\Shared;
4
5
use PHPExcel\Shared\Date;
6
7
class DateTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testSetExcelCalendar()
10
    {
11
        $calendarValues = array(
12
            Date::CALENDAR_MAC_1904,
13
            Date::CALENDAR_WINDOWS_1900,
14
        );
15
16
        foreach ($calendarValues as $calendarValue) {
17
            $result = call_user_func(array(Date::class,'setExcelCalendar'), $calendarValue);
18
            $this->assertTrue($result);
19
        }
20
    }
21
22
    public function testSetExcelCalendarWithInvalidValue()
23
    {
24
        $unsupportedCalendar = '2012';
25
        $result = call_user_func(array(Date::class,'setExcelCalendar'), $unsupportedCalendar);
26
        $this->assertFalse($result);
27
    }
28
29
    /**
30
     * @dataProvider providerDateTimeExcelToTimestamp1900
31
     */
32
    public function testDateTimeExcelToTimestamp1900()
33
    {
34
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
            array(Date::class,'setExcelCalendar'),
36
            Date::CALENDAR_WINDOWS_1900
37
        );
38
39
        $args = func_get_args();
40
        $expectedResult = array_pop($args);
41
        $result = call_user_func_array(array(Date::class, 'excelToTimestamp'), $args);
42
        $this->assertEquals($expectedResult, $result);
43
    }
44
45
    public function providerDateTimeExcelToTimestamp1900()
46
    {
47
        return include 'rawTestData/Shared/Date/ExcelToTimestamp1900.php';
48
    }
49
50
    /**
51
     * @dataProvider providerDateTimePHPToExcel1900
52
     */
53 View Code Duplication
    public function testDateTimePHPToExcel1900()
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...
54
    {
55
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
56
            array(Date::class,'setExcelCalendar'),
57
            Date::CALENDAR_WINDOWS_1900
58
        );
59
60
        $args = func_get_args();
61
        $expectedResult = array_pop($args);
62
        $result = call_user_func_array(array(Date::class,'PHPToExcel'), $args);
63
        $this->assertEquals($expectedResult, $result, null, 1E-5);
64
    }
65
66
    public function providerDateTimePHPToExcel1900()
67
    {
68
        return include 'rawTestData/Shared/Date/PHPToExcel1900.php';
69
    }
70
71
    /**
72
     * @dataProvider providerDateTimeFormattedPHPToExcel1900
73
     */
74 View Code Duplication
    public function testDateTimeFormattedPHPToExcel1900()
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...
75
    {
76
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
77
            array(Date::class,'setExcelCalendar'),
78
            Date::CALENDAR_WINDOWS_1900
79
        );
80
81
        $args = func_get_args();
82
        $expectedResult = array_pop($args);
83
        $result = call_user_func_array(array(Date::class,'formattedPHPToExcel'), $args);
84
        $this->assertEquals($expectedResult, $result, null, 1E-5);
85
    }
86
87
    public function providerDateTimeFormattedPHPToExcel1900()
88
    {
89
        return include 'rawTestData/Shared/Date/FormattedPHPToExcel1900.php';
90
    }
91
92
    /**
93
     * @dataProvider providerDateTimeExcelToTimestamp1904
94
     */
95 View Code Duplication
    public function testDateTimeExcelToTimestamp1904()
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...
96
    {
97
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
98
            array(Date::class,'setExcelCalendar'),
99
            Date::CALENDAR_MAC_1904
100
        );
101
102
        $args = func_get_args();
103
        $expectedResult = array_pop($args);
104
        $result = call_user_func_array(array(Date::class,'excelToTimestamp'), $args);
105
        $this->assertEquals($expectedResult, $result);
106
    }
107
108
    public function providerDateTimeExcelToTimestamp1904()
109
    {
110
        return include 'rawTestData/Shared/Date/ExcelToTimestamp1904.php';
111
    }
112
113
    /**
114
     * @dataProvider providerDateTimePHPToExcel1904
115
     */
116 View Code Duplication
    public function testDateTimePHPToExcel1904()
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...
117
    {
118
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
119
            array(Date::class,'setExcelCalendar'),
120
            Date::CALENDAR_MAC_1904
121
        );
122
123
        $args = func_get_args();
124
        $expectedResult = array_pop($args);
125
        $result = call_user_func_array(array(Date::class,'PHPToExcel'), $args);
126
        $this->assertEquals($expectedResult, $result, null, 1E-5);
127
    }
128
129
    public function providerDateTimePHPToExcel1904()
130
    {
131
        return include 'rawTestData/Shared/Date/PHPToExcel1904.php';
132
    }
133
134
    /**
135
     * @dataProvider providerIsDateTimeFormatCode
136
     */
137
    public function testIsDateTimeFormatCode()
138
    {
139
        $args = func_get_args();
140
        $expectedResult = array_pop($args);
141
        $result = call_user_func_array(array(Date::class,'isDateTimeFormatCode'), $args);
142
        $this->assertEquals($expectedResult, $result);
143
    }
144
145
    public function providerIsDateTimeFormatCode()
146
    {
147
        return include 'rawTestData/Shared/Date/FormatCodes.php';
148
    }
149
150
    /**
151
     * @dataProvider providerDateTimeExcelToTimestamp1900Timezone
152
     */
153 View Code Duplication
    public function testDateTimeExcelToTimestamp1900Timezone()
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...
154
    {
155
        $result = call_user_func(
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
156
            array(Date::class,'setExcelCalendar'),
157
            Date::CALENDAR_WINDOWS_1900
158
        );
159
160
        $args = func_get_args();
161
        $expectedResult = array_pop($args);
162
        $result = call_user_func_array(array(Date::class,'excelToTimestamp'), $args);
163
        $this->assertEquals($expectedResult, $result);
164
    }
165
166
    public function providerDateTimeExcelToTimestamp1900Timezone()
167
    {
168
        return include 'rawTestData/Shared/Date/ExcelToTimestamp1900Timezone.php';
169
    }
170
}
171