1 | <?php |
||
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() |
||
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() |
||
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() |
||
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() |
||
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.