|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP Billing Library |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/php-billing |
|
6
|
|
|
* @package php-billing |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hiqdev\php\billing\tests\unit\target; |
|
12
|
|
|
|
|
13
|
|
|
use hiqdev\php\billing\target\TargetCollection; |
|
14
|
|
|
use hiqdev\php\billing\target\Target; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Andrii Vasyliev <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class TargetTest extends \PHPUnit\Framework\TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
protected function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->aserver = new Target(null, 'server'); |
|
24
|
|
|
$this->server1 = new Target(1111, 'server'); |
|
25
|
|
|
$this->server2 = new Target(2222, 'server'); |
|
26
|
|
|
$this->servers = new TargetCollection([$this->server1, $this->server2]); |
|
27
|
|
|
$this->adomain = new Target(null, 'domain'); |
|
28
|
|
|
$this->domain1 = new Target(1111, 'domain'); |
|
29
|
|
|
$this->domain2 = new Target(2222, 'domain'); |
|
30
|
|
|
$this->domains = new TargetCollection([$this->domain1, $this->domain2]); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
protected function tearDown() |
|
34
|
|
|
{ |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testEquals() |
|
38
|
|
|
{ |
|
39
|
|
|
$aserver = new Target(null, 'server'); |
|
|
|
|
|
|
40
|
|
|
$server1 = new Target(1111, 'server'); |
|
41
|
|
|
$server2 = new Target(2222, 'server'); |
|
|
|
|
|
|
42
|
|
|
$servers = new TargetCollection([$this->server1, $this->server2]); |
|
|
|
|
|
|
43
|
|
|
$adomain = new Target(null, 'domain'); |
|
|
|
|
|
|
44
|
|
|
$domain1 = new Target(1111, 'domain'); |
|
|
|
|
|
|
45
|
|
|
$domain2 = new Target(2222, 'domain'); |
|
|
|
|
|
|
46
|
|
|
$domains = new TargetCollection([$this->domain1, $this->domain2]); |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
$this->assertTrue($this->server1->equals($server1)); |
|
49
|
|
|
$this->assertTrue($server1->equals($this->server1)); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertFalse($this->server1->equals($this->server2)); |
|
52
|
|
|
$this->assertFalse($this->server2->equals($this->server1)); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.