Completed
Pull Request — master (#1)
by Rafał
02:38
created

TenantableListenerSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace spec\SWP\MultiTenancyBundle\EventListener;
15
16
use PhpSpec\ObjectBehavior;
17
use SWP\Component\MultiTenancy\Model\Tenant;
18
use Symfony\Component\HttpFoundation\Request;
19
use Symfony\Component\HttpKernel\KernelEvents;
20
use Doctrine\ORM\EntityManagerInterface;
21
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
22
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
23
24
class TenantableListenerSpec extends ObjectBehavior
25
{
26
    public function let(
27
        EntityManagerInterface $entityManager,
28
        TenantContextInterface $tenantContext
29
    ) {
30
        $this->beConstructedWith($entityManager, $tenantContext);
31
    }
32
33
    public function it_is_initializable()
34
    {
35
        $this->shouldHaveType('SWP\MultiTenancyBundle\EventListener\TenantableListener');
36
    }
37
38
    public function it_implements_event_subscriber_interface()
39
    {
40
        $this->shouldImplement('Symfony\Component\EventDispatcher\EventSubscriberInterface');
41
    }
42
43
    public function it_subscribes_to_event()
44
    {
45
        $this::getSubscribedEvents()->shouldReturn([
46
            KernelEvents::REQUEST => 'onKernelRequest',
47
        ]);
48
    }
49
50
    public function it_skips_tenantable_filter_on_kernel_request(
51
        GetResponseEvent $event,
52
        $tenantContext,
53
        $entityManager
54
    ) {
55
        $tenantContext->getTenant()->shouldBeCalled()->willReturn(new Tenant());
56
        $entityManager->getFilters()->shouldNotBeCalled();
57
58
        $this->onKernelRequest($event)->shouldBeNull();
59
    }
60
}
61