1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy Bundle. |
7
|
|
|
* |
8
|
|
|
* Copyright 2017 Sourcefabric z.ú. and contributors. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please see the |
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* @copyright 2017 Sourcefabric z.ú |
14
|
|
|
* @license http://www.superdesk.org/license |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace spec\SWP\Bundle\MultiTenancyBundle\Form\Type; |
18
|
|
|
|
19
|
|
|
use PhpSpec\ObjectBehavior; |
20
|
|
|
use SWP\Bundle\MultiTenancyBundle\Form\Type\TenantChoiceType; |
21
|
|
|
use SWP\Component\MultiTenancy\Context\TenantContextInterface; |
22
|
|
|
use SWP\Component\MultiTenancy\Repository\TenantRepositoryInterface; |
23
|
|
|
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer; |
24
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
25
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
26
|
|
|
use Symfony\Component\Form\FormTypeInterface; |
27
|
|
|
|
28
|
|
|
final class TenantChoiceTypeSpec extends ObjectBehavior |
29
|
|
|
{ |
30
|
|
|
public function let(TenantRepositoryInterface $tenantRepository, TenantContextInterface $tenantContext) |
31
|
|
|
{ |
32
|
|
|
$this->beConstructedWith($tenantRepository, $tenantContext); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function it_is_initializable() |
36
|
|
|
{ |
37
|
|
|
$this->shouldHaveType(TenantChoiceType::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function it_should_be_a_form_type() |
41
|
|
|
{ |
42
|
|
|
$this->shouldHaveType(FormTypeInterface::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function it_should_build_form( |
46
|
|
|
FormBuilderInterface $builder |
47
|
|
|
) { |
48
|
|
|
$builder |
49
|
|
|
->addModelTransformer( |
50
|
|
|
new CollectionToArrayTransformer() |
51
|
|
|
)->shouldBeCalled(); |
52
|
|
|
|
53
|
|
|
$this->buildForm($builder, ['multiple' => true]); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function it_has_block_prefix() |
57
|
|
|
{ |
58
|
|
|
$this->getBlockPrefix()->shouldReturn('swp_tenant'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function it_should_have_a_parent() |
62
|
|
|
{ |
63
|
|
|
$this->getParent()->shouldReturn(ChoiceType::class); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|