Completed
Push — master ( 07e238...0f15f1 )
by Pavel
09:14
created

DeleteControllerTest   A

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 Prophecy\Argument;
8
use ScayTrase\Api\Cruds\Controller\DeleteController;
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
class DeleteControllerTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testDeleting()
17
    {
18
        $id = 241;
19
        $f1 = new AbcClass();
20
21
        $evm = $this->prophesize(EventDispatcherInterface::class);
22
        $evm->dispatch(CrudEvents::DELETE, Argument::type(CollectionCrudEvent::class))->shouldBeCalled();
23
24
        $repository = $this->prophesize(ObjectRepository::class);
25
        $repository->find(Argument::exact($id))->willReturn($f1)->shouldBeCalled();
26
27
        $manager = $this->prophesize(ObjectManager::class);
28
        $manager->remove(Argument::exact($f1))->shouldBeCalled();
29
        $manager->flush()->shouldBeCalled();
30
31
        $controller = new DeleteController($repository->reveal(), $manager->reveal(), $evm->reveal());
32
        $controller->deleteAction($id);
33
    }
34
}
35