Completed
Pull Request — master (#38)
by Marco
03:32
created

testWillCheckVisibleMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\ApiCompare\Comparator\BackwardsCompatibility\MethodBased;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Roave\ApiCompare\Change;
10
use Roave\ApiCompare\Changes;
11
use Roave\ApiCompare\Comparator\BackwardsCompatibility\FunctionBased\FunctionBased;
12
use Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MethodFunctionDefinitionChanged;
13
use Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MethodBased;
14
use Roave\BetterReflection\Reflection\ReflectionMethod;
15
16
/**
17
 * @covers \Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MethodFunctionDefinitionChanged
18
 */
19
final class MethodFunctionDefinitionChangedTest extends TestCase
20
{
21
    /** @var FunctionBased|MockObject */
22
    private $functionCheck;
23
24
    /** @var MethodBased */
25
    private $methodCheck;
26
27
    protected function setUp()
28
    {
29
        parent::setUp();
30
31
        $this->functionCheck = $this->createMock(FunctionBased::class);
32
        $this->methodCheck   = new MethodFunctionDefinitionChanged($this->functionCheck);
33
    }
34
35
    public function testWillCheckVisibleMethods() : void
36
    {
37
        /** @var ReflectionMethod|MockObject $to */
38
        $from = $this->createMock(ReflectionMethod::class);
39
        /** @var ReflectionMethod|MockObject $from */
40
        $to = $this->createMock(ReflectionMethod::class);
41
42
        $result = Changes::fromArray([
43
            Change::changed(uniqid('foo', true), true),
44
        ]);
45
46
        $this
47
            ->functionCheck
48
            ->expects(self::any())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Roave\ApiCompare\Compara...tionBased\FunctionBased. ( Ignorable by Annotation )

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

48
            ->/** @scrutinizer ignore-call */ 
49
              expects(self::any())

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...
49
            ->method('compare')
50
            ->with($from, $to)
51
            ->willReturn($result);
52
53
        self::assertEquals($result, $this->methodCheck->compare($from, $to));
54
    }
55
}
56