1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy Component. |
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\Component\MultiTenancy\Context; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use SWP\Component\MultiTenancy\Model\TenantInterface; |
18
|
|
|
|
19
|
|
|
class TenantContextSpec extends ObjectBehavior |
20
|
|
|
{ |
21
|
|
|
public function it_is_initializable() |
22
|
|
|
{ |
23
|
|
|
$this->shouldHaveType('SWP\Component\MultiTenancy\Context\TenantContext'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_implements_tenant_resolver_interface() |
27
|
|
|
{ |
28
|
|
|
$this->shouldImplement('SWP\Component\MultiTenancy\Context\TenantContextInterface'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
View Code Duplication |
public function it_should_set_tenant(TenantInterface $tenant) |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$tenant->getId()->willReturn(1); |
34
|
|
|
$tenant->getSubdomain()->willReturn('example1'); |
35
|
|
|
$tenant->getName()->willReturn('example1'); |
36
|
|
|
|
37
|
|
|
$this->setTenant($tenant)->shouldBeNull(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
View Code Duplication |
public function it_should_get_tenant(TenantInterface $tenant) |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
$tenant->getId()->willReturn(1); |
43
|
|
|
$tenant->getSubdomain()->willReturn('example1'); |
44
|
|
|
$tenant->getName()->willReturn('example1'); |
45
|
|
|
|
46
|
|
|
$this->setTenant($tenant)->shouldBeNull(); |
47
|
|
|
$this->getTenant()->shouldEqual($tenant); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function it_should_get_empty_tenant_object() |
51
|
|
|
{ |
52
|
|
|
$this->getTenant()->shouldReturnAnInstanceOf('SWP\Component\MultiTenancy\Model\TenantInterface'); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.