1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
use \FlexiPeeHP\Status; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-10-27 at 23:57:50. |
9
|
|
|
*/ |
10
|
|
|
class StatusTest extends FlexiBeeROTest |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Status |
14
|
|
|
*/ |
15
|
|
|
protected $object; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Sets up the fixture, for example, opens a network connection. |
19
|
|
|
* This method is called before a test is executed. |
20
|
|
|
*/ |
21
|
|
|
protected function setUp() |
22
|
|
|
{ |
23
|
|
|
$this->object = new \FlexiPeeHP\Status(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Tears down the fixture, for example, closes a network connection. |
28
|
|
|
* This method is called after a test is executed. |
29
|
|
|
*/ |
30
|
|
|
protected function tearDown() |
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testConstructor() |
36
|
|
|
{ |
37
|
|
|
$classname = get_class($this->object); |
38
|
|
|
$evidence = $this->object->getEvidence(); |
|
|
|
|
39
|
|
|
|
40
|
|
|
// Get mock, without the constructor being called |
41
|
|
|
$mock = $this->getMockBuilder($classname) |
42
|
|
|
->disableOriginalConstructor() |
43
|
|
|
->getMockForAbstractClass(); |
44
|
|
|
$mock->__construct(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @covers FlexiPeeHP\Status::getFlexiData |
49
|
|
|
*/ |
50
|
|
|
public function testGetFlexiData() |
51
|
|
|
{ |
52
|
|
|
$this->assertArrayKeyExists('version', $this->object->getFlexiData()); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @covers FlexiPeeHP\Status::unifyResponseFormat |
57
|
|
|
*/ |
58
|
|
|
public function testUnifyResponseFormat() |
59
|
|
|
{ |
60
|
|
|
$this->assertEquals(['success' => 'false'], |
61
|
|
|
$this->object->unifyResponseFormat(['success' => 'false'])); |
62
|
|
|
$this->assertEquals(['version' => 'ok'], |
63
|
|
|
$this->object->unifyResponseFormat(['status' => ['version' => 'ok']])); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
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.