1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace AlgoWeb\xsdTypes; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Generated Test Class. |
8
|
|
|
*/ |
9
|
|
|
class xsDateTimeTest extends \PHPUnit_Framework_TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Sets up the fixture, for example, opens a network connection. |
13
|
|
|
* This method is called before a test is executed. |
14
|
|
|
*/ |
15
|
|
|
protected function setUp() |
16
|
|
|
{ |
17
|
|
|
parent::setUp(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Tears down the fixture, for example, closes a network connection. |
22
|
|
|
* This method is called after a test is executed. |
23
|
|
|
*/ |
24
|
|
|
protected function tearDown() |
25
|
|
|
{ |
26
|
|
|
parent::tearDown(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @dataProvider testxsDateTimeValidDataProvider |
31
|
|
|
* @param mixed $input |
32
|
|
|
* @param mixed $message |
33
|
|
|
*/ |
34
|
|
|
public function testxsDateTimeValid($input, $message) |
35
|
|
|
{ |
36
|
|
|
try { |
37
|
|
|
$d = new xsDateTime($input); |
38
|
|
|
$e = (string)$d; |
|
|
|
|
39
|
|
|
} catch (\Exception $e) { |
40
|
|
|
$this->fail($message . ' with Exception ' . $e->getMessage()); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testxsDateTimeValidDataProvider() |
45
|
|
|
{ |
46
|
|
|
return array( |
47
|
|
|
array('2004-04-12T13:20:00', '1:20 pm on April 12, 2004'), |
48
|
|
|
array('2004-04-12T13:20:15.5', '1:20 pm and 15.5 seconds on April 12, 2004'), |
49
|
|
|
array('2004-04-12T13:20:00-05:00', '1:20 pm on April 12, 2004, US Eastern Standard Time'), |
50
|
|
|
array('2004-04-12T13:20:00Z', ' 1:20 pm on April 12, 2004, Coordinated Universal Time (UTC)'), |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @dataProvider testxsDateTimeInvalidDataProvider |
56
|
|
|
* @param mixed $input |
57
|
|
|
* @param mixed $message |
58
|
|
|
*/ |
59
|
|
|
public function testxsDateTimeInvalid($input, $message) |
60
|
|
|
{ |
61
|
|
|
try { |
62
|
|
|
$d = new xsDateTime($input); |
63
|
|
|
$s = (string)$d; |
64
|
|
|
$this->fail($message); |
65
|
|
|
} catch (\Exception $e) { |
|
|
|
|
66
|
|
|
} |
67
|
|
|
$this->assertEquals('', $s, $message); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testxsDateTimeInvalidDataProvider() |
71
|
|
|
{ |
72
|
|
|
return array( |
73
|
|
|
array('2004-04-12T13:00', 'seconds must be specified'), |
74
|
|
|
array('2004-04-1213:20:00', 'the letter T is required'), |
75
|
|
|
array('99-04-12T13:00', 'the century must not be left truncated'), |
76
|
|
|
array('2004-04-12', 'the time is required'), |
77
|
|
|
array('', 'an empty value is not valid, unless xsi:nil is used'), |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.