DoctrineSpec   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
B it_dispatches_domain_events_after_doctrine_unit_of_work_has_been_flushed() 0 26 1
1
<?php
2
3
namespace spec\Knp\RadBundle\DomainEvent\Dispatcher;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8
use Doctrine\ORM\Event\PostFlushEventArgs;
9
use Doctrine\ORM\EntityManager;
10
use Doctrine\ORM\UnitOfWork;
11
use Knp\RadBundle\DomainEvent\Provider;
12
use Knp\RadBundle\DomainEvent\Event;
13
use Doctrine\ORM\Event\LifecycleEventArgs;
14
15
class DoctrineSpec extends ObjectBehavior
16
{
17
    function let(EventDispatcherInterface $dispatcher)
18
    {
19
        $this->beConstructedWith($dispatcher);
20
    }
21
22
    function it_dispatches_domain_events_after_doctrine_unit_of_work_has_been_flushed(
0 ignored issues
show
Coding Style introduced by
Method name "DoctrineSpec::it_dispatches_domain_events_after_doctrine_unit_of_work_has_been_flushed" is not in camel caps format
Loading history...
23
        PostFlushEventArgs $postFlushEvent,
24
        LifecycleEventArgs $postPersistEvent,
25
        LifecycleEventArgs $postRemoveEvent,
26
        Provider $provider,
27
        Event $entityCreated,
28
        Event $propertyUpdated,
29
        NonProvider $nonProvider,
30
        $dispatcher
31
    ) {
32
        $postPersistEvent->getEntity()->willReturn($provider);
33
        $postRemoveEvent->getEntity()->willReturn($nonProvider);
34
35
        $provider->popEvents()->willReturn([$entityCreated, $propertyUpdated]);
36
        $entityCreated->getName()->willReturn('EntityCreated');
37
        $propertyUpdated->getName()->willReturn('PropertyUpdated');
38
39
        $entityCreated->setSubject($provider)->shouldBeCalled();
40
        $propertyUpdated->setSubject($provider)->shouldBeCalled();
41
        $dispatcher->dispatch('EntityCreated', $entityCreated)->shouldBeCalled();
42
        $dispatcher->dispatch('PropertyUpdated', $propertyUpdated)->shouldBeCalled();
43
44
        $this->postPersist($postPersistEvent);
45
        $this->postRemove($postRemoveEvent);
46
        $this->postFlush($postFlushEvent);
47
    }
48
}
49
50
class NonProvider
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
51
{
52
}
53