1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of CaptainHook. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace CaptainHook\App\Config; |
11
|
|
|
|
12
|
|
|
class ActionTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Tests Action::getType |
16
|
|
|
*/ |
17
|
|
|
public function testGetType() |
18
|
|
|
{ |
19
|
|
|
$action = new Action('php', '\\Foo\\Bar'); |
20
|
|
|
|
21
|
|
|
$this->assertEquals('php', $action->getType()); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Tests Action::getAction |
26
|
|
|
*/ |
27
|
|
|
public function testGetAction() |
28
|
|
|
{ |
29
|
|
|
$action = new Action('php', '\\Foo\\Bar'); |
30
|
|
|
$this->assertEquals('\\Foo\\Bar', $action->getAction()); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Tests Action::getOption |
35
|
|
|
*/ |
36
|
|
|
public function testGetOptions() |
37
|
|
|
{ |
38
|
|
|
$action = new Action('php', '\\Foo\\Bar'); |
39
|
|
|
$this->assertEquals([], $action->getOptions()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Tests Action::__construct |
44
|
|
|
*/ |
45
|
|
|
public function testEmptyOptions() |
46
|
|
|
{ |
47
|
|
|
$action = new Action('php', '\\Foo\\Bar'); |
48
|
|
|
$config = $action->getJsonData(); |
49
|
|
|
|
50
|
|
|
$this->assertEquals(0, count($config['options'])); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Tests Action::__construct |
55
|
|
|
* |
56
|
|
|
* @expectedException \Exception |
57
|
|
|
*/ |
58
|
|
|
public function testInvalidType() |
59
|
|
|
{ |
60
|
|
|
$action = new Action('crap', 'with cinnamon and sugar'); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
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.