Completed
Push — master ( 94e5ca...ea7499 )
by Matthieu
10s
created

ReflectionHelperTest::testMaintainPropertiesKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 21
rs 9.3142
c 2
b 1
f 0
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
namespace DeepCopyTest\Reflection;
3
4
use DeepCopy\Reflection\ReflectionHelper;
5
6
/**
7
 * Test ReflectionHelper
8
 */
9
class ReflectionHelperTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testMaintainPropertiesKey()
12
    {
13
        $child = new ReflectionHelperTestChild();
14
        $ref = new \ReflectionClass($child);
15
16
        $expectedProps = array(
17
            'a1',
18
            'a2',
19
            'a3',
20
            'a4',
21
            'a5',
22
            'a6',
23
            'a7',
24
            'a8',
25
            'a9',
26
        );
27
28
        $actualProps = ReflectionHelper::getProperties($ref);
29
30
        $this->assertSame($expectedProps, array_keys($actualProps));
31
    }
32
}
33
34
class ReflectionHelperTestParent {
35
    public $a1;
36
    protected $a2;
37
    private $a3;
0 ignored issues
show
Unused Code introduced by Filippo Tessarotto
The property $a3 is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
38
39
    public $a4;
40
    protected $a5;
41
    private $a6;
0 ignored issues
show
Unused Code introduced by Filippo Tessarotto
The property $a6 is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
42
}
43
44
class ReflectionHelperTestChild extends ReflectionHelperTestParent {
45
    public $a1;
46
    protected $a2;
47
    private $a3;
0 ignored issues
show
Comprehensibility introduced by Filippo Tessarotto
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by Filippo Tessarotto
The property $a3 is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
48
49
    public $a7;
50
    protected $a8;
51
    private $a9;
0 ignored issues
show
Unused Code introduced by Filippo Tessarotto
The property $a9 is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
52
}
53