Completed
Push — master ( 6f962e...549eec )
by Kamil
21:17
created

CallbackSchemaSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 39
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_schema_interface() 0 4 1
A it_uses_callback_to_build_settings() 0 10 1
A it_uses_callback_to_build_form() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Bundle\SettingsBundle\Schema;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\SettingsBundle\Schema\CallbackSchema;
17
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
18
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
19
use Symfony\Component\Form\FormBuilderInterface;
20
21
/**
22
 * @mixin CallbackSchema
23
 *
24
 * @author Kamil Kokot <[email protected]>
25
 */
26
final class CallbackSchemaSpec extends ObjectBehavior
27
{
28
    function let()
29
    {
30
        $this->beConstructedWith(function (){}, function (){});
31
    }
32
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType('Sylius\Bundle\SettingsBundle\Schema\CallbackSchema');
36
    }
37
38
    function it_implements_schema_interface()
39
    {
40
        $this->shouldImplement(SchemaInterface::class);
41
    }
42
43
    function it_uses_callback_to_build_settings(SettingsBuilderInterface $settingsBuilder)
44
    {
45
        $this->beConstructedWith(function (SettingsBuilderInterface $settingsBuilder) {
46
            $settingsBuilder->setDefaults(['foo' => 'bar']);
47
        }, function (){});
48
49
        $settingsBuilder->setDefaults(['foo' => 'bar'])->shouldBeCalled();
50
51
        $this->buildSettings($settingsBuilder);
52
    }
53
54
    function it_uses_callback_to_build_form(FormBuilderInterface $formBuilder)
55
    {
56
        $this->beConstructedWith(function (){}, function (FormBuilderInterface $formBuilder) {
57
            $formBuilder->add('bono', 'u2');
58
        });
59
60
        $formBuilder->add('bono', 'u2')->shouldBeCalled();
61
62
        $this->buildForm($formBuilder);
63
    }
64
}
65