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