Passed
Pull Request — master (#50)
by Marco
02:46
created

UseClassBasedChecksOnATraitTest::testCompare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\DetectChanges\BCBreak\TraitBased;
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\TraitBased\UseClassBasedChecksOnATrait;
13
use Roave\BetterReflection\Reflection\ReflectionClass;
14
use function uniqid;
15
16
/**
17
 * @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\TraitBased\UseClassBasedChecksOnATrait
18
 */
19
final class UseClassBasedChecksOnATraitTest extends TestCase
20
{
21
    public function testCompare() : void
22
    {
23
        $changes = Changes::fromList(Change::added(uniqid('foo', true), true));
24
25
        /** @var ClassBased|MockObject $classBased */
26
        $classBased = $this->createMock(ClassBased::class);
27
        /** @var ReflectionClass|MockObject $fromTrait */
28
        $fromTrait = $this->createMock(ReflectionClass::class);
29
        /** @var ReflectionClass|MockObject $toTrait */
30
        $toTrait = $this->createMock(ReflectionClass::class);
31
32
        $classBased
33
            ->expects(self::once())
0 ignored issues
show
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

33
            ->/** @scrutinizer ignore-call */ 
34
              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...
34
            ->method('__invoke')
35
            ->with($fromTrait, $toTrait)
36
            ->willReturn($changes);
37
38
        self::assertSame($changes, (new UseClassBasedChecksOnATrait($classBased))->__invoke($fromTrait, $toTrait));
39
    }
40
}
41