ReadControllerTest::testGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Unit\Controller;
4
5
use Doctrine\Common\Persistence\ObjectRepository;
6
use PHPUnit\Framework\TestCase;
7
use Prophecy\Argument;
8
use ScayTrase\Api\Cruds\Controller\ReadController;
9
use ScayTrase\Api\Cruds\Event\CollectionCrudEvent;
10
use ScayTrase\Api\Cruds\Event\CrudEvents;
11
use ScayTrase\Api\Cruds\Tests\Fixtures\AbcClass;
12
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13
14
final class ReadControllerTest extends TestCase
15
{
16
    public function testGet()
17
    {
18
        $id = 241;
19
        $f1 = new AbcClass();
20
21
        $evm = $this->prophesize(EventDispatcherInterface::class);
22
        $evm->dispatch(CrudEvents::READ, Argument::type(CollectionCrudEvent::class))->shouldBeCalled();
23
24
        $repository = $this->prophesize(ObjectRepository::class);
25
        $repository->find(Argument::exact($id))->willReturn($f1)->shouldBeCalled();
26
27
        $controller = new ReadController($repository->reveal(), $evm->reveal());
28
29
        /** @var AbcClass $entity */
30
        $entity = $controller->getAction($id);
31
        self::assertSame($f1, $entity);
32
    }
33
}
34