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

testNormalMethodsAreNotExcluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
rs 9.7333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\MethodBased;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Change;
9
use Roave\BackwardCompatibility\Changes;
10
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\ExcludeInternalMethod;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased\MethodBased;
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\MethodBased\ExcludeInternalMethod */
17
final class ExcludeInternalMethodTest extends TestCase
18
{
19
    public function testNormalMethodsAreNotExcluded() : void
20
    {
21
        $method = (new ClassReflector(new StringSourceLocator(
22
            <<<'PHP'
23
<?php
24
25
class A {
26
    function method() {}
27
}
28
PHP
29
            ,
30
            (new BetterReflection())->astLocator()
31
        )))
32
            ->reflect('A')
33
            ->getMethod('method');
34
35
        $check = $this->createMock(MethodBased::class);
36
        $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

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

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

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

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

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

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