Completed
Push — master ( eebbc1...b931d6 )
by mw
225:23 queued 190:29
created

JulianDayTest::testConvert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\Tests\DataValues\Time;
4
5
use SMW\DataValues\Time\JulianDay;
6
7
/**
8
 * @covers \SMW\DataValues\Time\JulianDay
9
 * @group semantic-mediawiki
10
 *
11
 * @license GNU GPL v2+
12
 * @since 2.4
13
 *
14
 * @author mwjames
15
 */
16
class JulianDayTest extends \PHPUnit_Framework_TestCase {
17
18
	/**
19
	 * @dataProvider valueProvider
20
	 */
21
	public function testConvert( $calendarModel, $seralization, $jdValue ) {
22
23
		list( $year, $month, $day, $hour, $minute, $second ) = explode( '/', $seralization );
24
25
		$this->assertEquals(
26
			$jdValue,
27
			JulianDay::getJD( $calendarModel, $year, $month, $day, $hour, $minute, $second )
28
		);
29
	}
30
31
	public function valueProvider() {
32
33
		$provider[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
34
			JulianDay::CM_JULIAN,
35
			'1352/01/01/0/0/0',
36
			'2214875.500000'
37
		);
38
39
		$provider[] = array(
40
			JulianDay::CM_GREGORIAN,
41
			'2100/10/04/0/0/0',
42
			'2488345.500000'
43
		);
44
45
		$provider[] = array(
46
			JulianDay::CM_GREGORIAN,
47
			'2100/10/04/0/0/0',
48
			'2488345.500000'
49
		);
50
51
		$provider[] = array(
52
			JulianDay::CM_JULIAN,
53
			'1582/10/04/0/0/0',
54
			'2299159.500000'
55
		);
56
57
		$provider[] = array(
58
			JulianDay::CM_GREGORIAN,
59
			'1582/10/15/0/0/0',
60
			'2299160.5'
61
		);
62
63
		$provider[] = array(
64
			JulianDay::CM_JULIAN,
65
			'-900/10/4/0/0/0',
66
			'1392974.500000'
67
		);
68
69
		$provider[] = array(
70
			JulianDay::CM_JULIAN,
71
			'-4713/01/02/0/0/0',
72
			'0.5'
73
		);
74
75
		$provider[] = array(
76
			JulianDay::CM_JULIAN,
77
			'-4713/01/02/12/0/0/0',
78
			'1'
79
		);
80
81
		$provider[] = array(
82
			JulianDay::CM_JULIAN,
83
			'-9000/10/4/0/0/0',
84
			'-1565550.5'
85
		);
86
87
		$provider[] = array(
88
			JulianDay::CM_GREGORIAN,
89
			'2100/10/4/13/55/55',
90
			'2488346.0804977'
91
		);
92
93
		$provider[] = array(
94
			JulianDay::CM_GREGORIAN,
95
			'2100/10/4/13/55/55',
96
			2488346.0804977
97
		);
98
99
		return $provider;
100
	}
101
102
}
103