Completed
Push — master ( 85853a...5df06c )
by James
20s queued 12s
created

testNormalPropertiesAreNotExcluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 28
rs 9.7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Change;
9
use Roave\BackwardCompatibility\Changes;
10
use Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased\ExcludeInternalProperty;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased\PropertyBased;
12
use Roave\BetterReflection\BetterReflection;
13
use Roave\BetterReflection\Reflector\ClassReflector;
14
use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator;
15
16
/** @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased\ExcludeInternalProperty */
17
final class ExcludeInternalPropertyTest extends TestCase
18
{
19
    public function testNormalPropertiesAreNotExcluded() : void
20
    {
21
        $property = (new ClassReflector(new StringSourceLocator(
22
            <<<'PHP'
23
<?php
24
25
class A {
26
    public $property;
27
}
28
PHP
29
            ,
30
            (new BetterReflection())->astLocator()
31
        )))
32
            ->reflect('A')
33
            ->getProperty('property');
34
35
        self::assertNotNull($property);
36
37
        $check = $this->createMock(PropertyBased::class);
38
        $check->expects(self::once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $check->/** @scrutinizer ignore-call */ 
39
                expects(self::once())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method once() does not exist on RoaveTest\BackwardCompat...udeInternalPropertyTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $check->expects(self::/** @scrutinizer ignore-call */ once())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
              ->method('__invoke')
40
              ->with($property, $property)
41
              ->willReturn(Changes::fromList(Change::removed('foo', true)));
42
43
        self::assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on RoaveTest\BackwardCompat...udeInternalPropertyTest. Did you maybe mean assertFalse()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        self::/** @scrutinizer ignore-call */ 
44
              assertEquals(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
            Changes::fromList(Change::removed('foo', true)),
45
            (new ExcludeInternalProperty($check))
46
                ->__invoke($property, $property)
0 ignored issues
show
Bug introduced by
It seems like $property can also be of type null; however, parameter $toProperty of Roave\BackwardCompatibil...nalProperty::__invoke() does only seem to accept Roave\BetterReflection\R...tion\ReflectionProperty, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
                ->__invoke($property, /** @scrutinizer ignore-type */ $property)
Loading history...
Bug introduced by
It seems like $property can also be of type null; however, parameter $fromProperty of Roave\BackwardCompatibil...nalProperty::__invoke() does only seem to accept Roave\BetterReflection\R...tion\ReflectionProperty, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
                ->__invoke(/** @scrutinizer ignore-type */ $property, $property)
Loading history...
47
        );
48
    }
49
50
    public function testInternalPropertiesAreExcluded() : void
51
    {
52
        $property = (new ClassReflector(new StringSourceLocator(
53
            <<<'PHP'
54
<?php
55
56
class A {
57
    /** @internal */
58
    public $property;
59
}
60
PHP
61
            ,
62
            (new BetterReflection())->astLocator()
63
        )))
64
            ->reflect('A')
65
            ->getProperty('property');
66
67
        self::assertNotNull($property);
68
69
        $check = $this->createMock(PropertyBased::class);
70
        $check->expects(self::never())
0 ignored issues
show
Bug introduced by
The method never() does not exist on RoaveTest\BackwardCompat...udeInternalPropertyTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        $check->expects(self::/** @scrutinizer ignore-call */ never())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
              ->method('__invoke');
72
73
        self::assertEquals(
74
            Changes::empty(),
75
            (new ExcludeInternalProperty($check))
76
                ->__invoke($property, $property)
0 ignored issues
show
Bug introduced by
It seems like $property can also be of type null; however, parameter $toProperty of Roave\BackwardCompatibil...nalProperty::__invoke() does only seem to accept Roave\BetterReflection\R...tion\ReflectionProperty, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
                ->__invoke($property, /** @scrutinizer ignore-type */ $property)
Loading history...
Bug introduced by
It seems like $property can also be of type null; however, parameter $fromProperty of Roave\BackwardCompatibil...nalProperty::__invoke() does only seem to accept Roave\BetterReflection\R...tion\ReflectionProperty, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
                ->__invoke(/** @scrutinizer ignore-type */ $property, $property)
Loading history...
77
        );
78
    }
79
}
80