DeleteControllerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 21
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testDeleting() 0 18 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Unit\Controller;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
use Doctrine\Common\Persistence\ObjectRepository;
7
use PHPUnit\Framework\TestCase;
8
use Prophecy\Argument;
9
use ScayTrase\Api\Cruds\Controller\DeleteController;
10
use ScayTrase\Api\Cruds\Event\CollectionCrudEvent;
11
use ScayTrase\Api\Cruds\Event\CrudEvents;
12
use ScayTrase\Api\Cruds\Tests\Fixtures\AbcClass;
13
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
14
15
final class DeleteControllerTest extends TestCase
16
{
17
    public function testDeleting()
18
    {
19
        $id = 241;
20
        $f1 = new AbcClass();
21
22
        $evm = $this->prophesize(EventDispatcherInterface::class);
23
        $evm->dispatch(CrudEvents::DELETE, Argument::type(CollectionCrudEvent::class))->shouldBeCalled();
24
25
        $repository = $this->prophesize(ObjectRepository::class);
26
        $repository->find(Argument::exact($id))->willReturn($f1)->shouldBeCalled();
27
28
        $manager = $this->prophesize(ObjectManager::class);
29
        $manager->remove(Argument::exact($f1))->shouldBeCalled();
30
        $manager->flush()->shouldBeCalled();
31
32
        $controller = new DeleteController($repository->reveal(), $manager->reveal(), $evm->reveal());
33
        $controller->deleteAction($id);
34
    }
35
}
36