EventRepositoryTest::testCreateFromDomainEvent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\Entity;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use JMS\Serializer\SerializerBuilder;
7
use Knp\Component\Pager\PaginatorInterface;
8
use Loevgaard\DandomainAltapayBundle\Entity\Event;
9
use Loevgaard\DandomainAltapayBundle\Entity\EventRepository;
10
use Loevgaard\DandomainAltapayBundle\Entity\Payment;
11
use Loevgaard\DandomainAltapayBundle\Event\PaymentCreated;
12
use PHPUnit\Framework\TestCase;
13
14
class EventRepositoryTest extends TestCase
15
{
16
    public function testCreateFromDomainEvent()
17
    {
18
        $serializer = SerializerBuilder::create()->build();
19
        $managerRegistry = $this->createMock(ManagerRegistry::class);
20
        $managerRegistry->method('getManagerForClass')->willReturn(null);
21
        $paginator = $this->createMock(PaginatorInterface::class);
22
23
        $domainEvent = new PaymentCreated(new Payment());
24
25
        $expectedEvent = new Event($domainEvent->getName(), $serializer->serialize($domainEvent, 'json'));
26
27
        $eventRepository = new EventRepository($managerRegistry, $paginator, 'class', $serializer);
0 ignored issues
show
Documentation introduced by
$managerRegistry is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\Common\P...stence\ManagerRegistry>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$paginator is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Knp\Component\Pager\PaginatorInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29
        $this->assertEquals($expectedEvent, $eventRepository->createFromDomainEvent($domainEvent));
30
    }
31
}
32