Failed Conditions
Pull Request — master (#94)
by Benjamin
05:18 queued 02:45
created

RuntimeReflectionServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
eloc 14
c 3
b 1
f 0
dl 0
loc 33
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testGetTypedDefaultReflectionProperty() 0 5 1
A testGetTypedNoDefaultReflectionProperty() 0 4 1
A testGetTypedPublicNoDefaultPropertyWorksWithGetValue() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests_PHP74\Persistence\Mapping;
6
7
use Doctrine\Common\Reflection\TypedNoDefaultReflectionProperty;
8
use Doctrine\Common\Reflection\RuntimePublicReflectionProperty;
0 ignored issues
show
Coding Style introduced by
Use statements should be sorted alphabetically. The first wrong one is Doctrine\Common\Reflection\RuntimePublicReflectionProperty.
Loading history...
9
use Doctrine\Persistence\Mapping\RuntimeReflectionService;
10
use PHPUnit\Framework\TestCase;
11
use ReflectionProperty;
12
13
/**
14
 * @group DCOM-93
15
 */
16
class RuntimeReflectionServiceTest extends TestCase
17
{
18
    /** @var RuntimeReflectionService */
19
    private $reflectionService;
20
21
    private string $typedNoDefaultProperty;
0 ignored issues
show
introduced by
The private property $typedNoDefaultProperty is not used, and could be removed.
Loading history...
22
    private string $typedDefaultProperty = '';
0 ignored issues
show
introduced by
The private property $typedDefaultProperty is not used, and could be removed.
Loading history...
23
24
    public string $typedNoDefaultPublicProperty;
25
26
    protected function setUp() : void
27
    {
28
        $this->reflectionService = new RuntimeReflectionService();
29
    }
30
31
    public function testGetTypedNoDefaultReflectionProperty() : void
32
    {
33
        $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'typedNoDefaultProperty');
34
        self::assertInstanceOf(TypedNoDefaultReflectionProperty::class, $reflProp);
35
    }
36
37
    public function testGetTypedDefaultReflectionProperty() : void
38
    {
39
        $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'typedDefaultProperty');
40
        self::assertInstanceOf(ReflectionProperty::class, $reflProp);
41
        self::assertNotInstanceOf(TypedNoDefaultReflectionProperty::class, $reflProp);
42
    }
43
44
    public function testGetTypedPublicNoDefaultPropertyWorksWithGetValue() : void
45
    {
46
        $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'typedNoDefaultPublicProperty');
47
        self::assertInstanceOf(RuntimePublicReflectionProperty::class, $reflProp);
48
        $this->assertNull($reflProp->getValue($this));
49
    }
50
}
51