|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy Bundle. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2016 Sourcefabric z.ú. 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 2016 Sourcefabric z.ú. |
|
12
|
|
|
* @license http://www.superdesk.org/license |
|
13
|
|
|
*/ |
|
14
|
|
|
namespace spec\SWP\Bundle\MultiTenancyBundle\Factory; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
17
|
|
|
use Doctrine\ODM\PHPCR\HierarchyInterface; |
|
18
|
|
|
use PhpSpec\ObjectBehavior; |
|
19
|
|
|
use SWP\Bundle\MultiTenancyBundle\Factory\OrganizationFactory; |
|
20
|
|
|
use SWP\Bundle\MultiTenancyBundle\spec\ParentTest; |
|
21
|
|
|
use SWP\Component\MultiTenancy\Factory\OrganizationFactoryInterface; |
|
22
|
|
|
use SWP\Component\MultiTenancy\Model\OrganizationInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @mixin OrganizationFactory |
|
26
|
|
|
*/ |
|
27
|
|
|
class OrganizationFactorySpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function let( |
|
30
|
|
|
OrganizationFactoryInterface $factory, |
|
31
|
|
|
ObjectManager $documentManager |
|
32
|
|
|
) { |
|
33
|
|
|
$this->beConstructedWith($factory, $documentManager, '/swp'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_is_initializable() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldHaveType(OrganizationFactory::class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_implements_tenant_factory_interface() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->shouldImplement(OrganizationFactoryInterface::class); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_creates_empty_organization( |
|
47
|
|
|
OrganizationFactoryInterface $factory, |
|
48
|
|
|
OrganizationInterface $organization |
|
49
|
|
|
) { |
|
50
|
|
|
$factory->create()->willReturn($organization); |
|
51
|
|
|
|
|
52
|
|
|
$this->create()->shouldReturn($organization); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_creates_a_new_organization_with_code( |
|
56
|
|
|
OrganizationFactoryInterface $factory, |
|
57
|
|
|
OrganizationInterface $organization |
|
58
|
|
|
) { |
|
59
|
|
|
$factory->createWithCode()->willReturn($organization); |
|
60
|
|
|
|
|
61
|
|
|
$this->createWithCode()->shouldReturn($organization); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
function it_creates_a_new_organization_with_code_and_parent_document( |
|
65
|
|
|
OrganizationFactoryInterface $factory, |
|
66
|
|
|
ObjectManager $documentManager |
|
67
|
|
|
) { |
|
68
|
|
|
$organization = new ParentTest(); |
|
69
|
|
|
|
|
70
|
|
|
$factory->createWithCode()->willReturn($organization); |
|
71
|
|
|
|
|
72
|
|
|
$documentManager->find(null, '/swp')->shouldBeCalled(); |
|
73
|
|
|
|
|
74
|
|
|
$this->createWithCode()->shouldHaveType(HierarchyInterface::class); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|