Passed
Pull Request — master (#38)
by Marco
02:40
created

MethodFunctionDefinitionChangedTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testWillCheckVisibleMethods() 0 19 1
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\MethodBased;
13
use Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MethodFunctionDefinitionChanged;
14
use Roave\BetterReflection\Reflection\ReflectionMethod;
15
use function uniqid;
16
17
/**
18
 * @covers \Roave\ApiCompare\Comparator\BackwardsCompatibility\MethodBased\MethodFunctionDefinitionChanged
19
 */
20
final class MethodFunctionDefinitionChangedTest extends TestCase
21
{
22
    /** @var FunctionBased|MockObject */
23
    private $functionCheck;
24
25
    /** @var MethodBased */
26
    private $methodCheck;
27
28
    protected function setUp() : void
29
    {
30
        parent::setUp();
31
32
        $this->functionCheck = $this->createMock(FunctionBased::class);
33
        $this->methodCheck   = new MethodFunctionDefinitionChanged($this->functionCheck);
34
    }
35
36
    public function testWillCheckVisibleMethods() : void
37
    {
38
        /** @var ReflectionMethod|MockObject $to */
39
        $from = $this->createMock(ReflectionMethod::class);
40
        /** @var ReflectionMethod|MockObject $from */
41
        $to = $this->createMock(ReflectionMethod::class);
42
43
        $result = Changes::fromArray([
44
            Change::changed(uniqid('foo', true), true),
45
        ]);
46
47
        $this
48
            ->functionCheck
49
            ->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

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