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

testNormalClassesAreNotExcluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
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 26
rs 9.7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\ClassBased;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Roave\BackwardCompatibility\Change;
10
use Roave\BackwardCompatibility\Changes;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassBased\ClassBased;
12
use Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassBased\ExcludeInternalClass;
13
use Roave\BetterReflection\BetterReflection;
14
use Roave\BetterReflection\Reflector\ClassReflector;
15
use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator;
16
17
/** @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassBased\ExcludeInternalClass */
18
final class ExcludeInternalClassTest extends TestCase
19
{
20
    public function testNormalClassesAreNotExcluded() : void
21
    {
22
        $locator        = (new BetterReflection())->astLocator();
23
        $reflector      = new ClassReflector(new StringSourceLocator(
24
            <<<'PHP'
25
<?php
26
27
class ANormalClass {}
28
PHP
29
            ,
30
            $locator
31
        ));
32
        $fromReflection = $reflector->reflect('ANormalClass');
33
        $toReflection   = $reflector->reflect('ANormalClass');
34
35
        /** @var ClassBased&MockObject $check */
36
        $check = $this->createMock(ClassBased::class);
37
        $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

37
        $check->/** @scrutinizer ignore-call */ 
38
                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 expects() does not exist on Roave\BackwardCompatibil...k\ClassBased\ClassBased. ( Ignorable by Annotation )

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

37
        $check->/** @scrutinizer ignore-call */ 
38
                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...xcludeInternalClassTest. ( Ignorable by Annotation )

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

37
        $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...
38
              ->method('__invoke')
39
              ->with($fromReflection, $toReflection)
40
              ->willReturn(Changes::fromList(Change::removed('foo', true)));
41
42
        self::assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on RoaveTest\BackwardCompat...xcludeInternalClassTest. 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

42
        self::/** @scrutinizer ignore-call */ 
43
              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...
43
            Changes::fromList(Change::removed('foo', true)),
44
            (new ExcludeInternalClass($check))
45
                ->__invoke($fromReflection, $toReflection)
46
        );
47
    }
48
49
    public function testInternalClassesAreExcluded() : void
50
    {
51
        $locator    = (new BetterReflection())->astLocator();
52
        $reflector  = new ClassReflector(new StringSourceLocator(
53
            <<<'PHP'
54
<?php
55
56
/** @internal */
57
class AnInternalClass {}
58
PHP
59
            ,
60
            $locator
61
        ));
62
        $reflection = $reflector->reflect('AnInternalClass');
63
64
        $check = $this->createMock(ClassBased::class);
65
        $check->expects(self::never())->method('__invoke');
0 ignored issues
show
Bug introduced by
The method never() does not exist on RoaveTest\BackwardCompat...xcludeInternalClassTest. ( Ignorable by Annotation )

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

65
        $check->expects(self::/** @scrutinizer ignore-call */ never())->method('__invoke');

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...
66
67
        self::assertEquals(
68
            Changes::empty(),
69
            (new ExcludeInternalClass($check))
70
                ->__invoke($reflection, $reflection)
71
        );
72
    }
73
}
74