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

testInternalFunctionsAreExcluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.7998
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Change;
9
use Roave\BackwardCompatibility\Changes;
10
use Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\ExcludeInternalFunction;
11
use Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\FunctionBased;
12
use Roave\BetterReflection\BetterReflection;
13
use Roave\BetterReflection\Reflector\ClassReflector;
14
use Roave\BetterReflection\Reflector\FunctionReflector;
15
use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator;
16
17
/** @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\ExcludeInternalFunction */
18
final class ExcludeInternalFunctionTest extends TestCase
19
{
20
    public function testNormalFunctionsAreNotExcluded() : void
21
    {
22
        $source   = new StringSourceLocator(
23
            <<<'PHP'
24
<?php
25
26
function a() {}
27
PHP
28
            ,
29
            (new BetterReflection())->astLocator()
30
        );
31
        $function = (new FunctionReflector($source, new ClassReflector($source)))
32
            ->reflect('a');
33
34
        $check = $this->createMock(FunctionBased::class);
35
        $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

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

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

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

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

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

63
        $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...
64
              ->method('__invoke');
65
66
        self::assertEquals(
67
            Changes::empty(),
68
            (new ExcludeInternalFunction($check))
69
                ->__invoke($function, $function)
70
        );
71
    }
72
}
73