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\Component\Grid\Definition; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Component\Grid\Definition\Field; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
final class FieldSpec extends ObjectBehavior |
21
|
|
|
{ |
22
|
|
|
function let() |
23
|
|
|
{ |
24
|
|
|
$this->beConstructedThrough('fromNameAndType', ['enabled', 'boolean']); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
function it_is_initializable() |
28
|
|
|
{ |
29
|
|
|
$this->shouldHaveType(Field::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_has_name() |
33
|
|
|
{ |
34
|
|
|
$this->getName()->shouldReturn('enabled'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_has_type() |
38
|
|
|
{ |
39
|
|
|
$this->getType()->shouldReturn('boolean'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
function it_has_path_which_defaults_to_name() |
43
|
|
|
{ |
44
|
|
|
$this->getPath()->shouldReturn('enabled'); |
45
|
|
|
|
46
|
|
|
$this->setPath('method.enabled'); |
47
|
|
|
$this->getPath()->shouldReturn('method.enabled'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_has_label_which_defaults_to_name() |
51
|
|
|
{ |
52
|
|
|
$this->getLabel()->shouldReturn('enabled'); |
53
|
|
|
|
54
|
|
|
$this->setLabel('Is enabled?'); |
55
|
|
|
$this->getLabel()->shouldReturn('Is enabled?'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function it_is_toggleable() |
59
|
|
|
{ |
60
|
|
|
$this->isEnabled()->shouldReturn(true); |
61
|
|
|
|
62
|
|
|
$this->setEnabled(false); |
63
|
|
|
$this->isEnabled()->shouldReturn(false); |
64
|
|
|
$this->setEnabled(true); |
65
|
|
|
$this->isEnabled()->shouldReturn(true); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
function it_knows_by_which_property_it_can_be_sorted() |
69
|
|
|
{ |
70
|
|
|
$this->getSortable()->shouldReturn(null); |
71
|
|
|
|
72
|
|
|
$this->setSortable('method.enabled'); |
73
|
|
|
$this->getSortable()->shouldReturn('method.enabled'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
function its_sorted_by_name_when_sortable_is_not_set() |
77
|
|
|
{ |
78
|
|
|
$this->getSortable()->shouldReturn(null); |
79
|
|
|
|
80
|
|
|
$this->setSortable(null); |
81
|
|
|
$this->getSortable()->shouldReturn('enabled'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
function it_has_no_options_by_default() |
85
|
|
|
{ |
86
|
|
|
$this->getOptions()->shouldReturn([]); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
function it_can_have_options() |
90
|
|
|
{ |
91
|
|
|
$this->setOptions(['template' => 'SyliusUiBundle:Grid/Field:_status.html.twig']); |
92
|
|
|
$this->getOptions()->shouldReturn(['template' => 'SyliusUiBundle:Grid/Field:_status.html.twig']); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
function it_has_last_position_by_default() |
96
|
|
|
{ |
97
|
|
|
$this->getPosition()->shouldReturn(100); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
function its_position_is_mutable() |
101
|
|
|
{ |
102
|
|
|
$this->setPosition(1); |
103
|
|
|
$this->getPosition()->shouldReturn(1); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|