Skip to content

Commit bfc9a39

Browse files
author
Timm Ortloff
committed
WIP: Convert CollectionTest to use the new Collection methods
1 parent 66146e3 commit bfc9a39

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/CollectionTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use InvalidArgumentException;
66
use ipl\Html\FormDecorator\DivDecorator;
77
use ipl\Html\FormElement\Collection;
8+
use ipl\Html\FormElement\SelectElement;
9+
use ipl\Html\FormElement\SubmitButtonElement;
810

911
class CollectionTest extends TestCase
1012
{
@@ -67,13 +69,12 @@ public function testNoRemoveTriggerProvided()
6769

6870
public function testAddTrigger()
6971
{
70-
$this->collection->setAddElement('select', 'add_element', [
72+
$this->collection->setAddElement(new SelectElement('add_element', [
7173
'required' => false,
7274
'label' => 'Add Trigger',
7375
'options' => [null => 'Please choose', 'first' => 'First Option'],
7476
'class' => 'autosubmit'
75-
]);
76-
77+
]));
7778

7879
$this->collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
7980
$group->setDefaultElementDecorator(new DivDecorator());
@@ -106,12 +107,11 @@ public function testAddTrigger()
106107
$this->assertHtml($expected, $this->collection);
107108
}
108109

109-
110110
public function testRemoveTrigger()
111111
{
112-
$this->collection->setRemoveElement('submitButton', 'remove_trigger', [
112+
$this->collection->setRemoveElement(new SubmitButtonElement('remove_trigger', [
113113
'label' => 'Remove Trigger',
114-
]);
114+
]));
115115

116116
$this->collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
117117
$group->setDefaultElementDecorator(new DivDecorator());
@@ -144,17 +144,17 @@ public function testRemoveTrigger()
144144
public function testFullCollection()
145145
{
146146
$this->collection->setLabel($this->label);
147-
$this->collection->setAddElement('select', 'add_element', [
147+
$this->collection->setAddElement(new SelectElement('add_element', [
148148
'required' => false,
149149
'label' => 'Add Trigger',
150150
'options' => [null => 'Please choose', 'first' => 'First Option'],
151151
'class' => 'autosubmit'
152-
]);
152+
]));
153153

154-
$this->collection->setRemoveElement('submitButton', 'remove_trigger', [
154+
$this->collection->setRemoveElement(new SubmitButtonElement('remove_trigger', [
155155
'label' => 'Remove Trigger',
156156
'value' => 'Remove Trigger'
157-
]);
157+
]));
158158

159159
$this->collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
160160
$group->setDefaultElementDecorator(new DivDecorator());
@@ -201,21 +201,21 @@ public function testFullCollection()
201201

202202
public function testMultipleCollections()
203203
{
204-
$this->collection->setAddElement('select', 'add_element', [
204+
$this->collection->setAddElement(new SelectElement('add_element', [
205205
'required' => false,
206206
'label' => 'Add Trigger',
207207
'options' => [null => 'Please choose', 'first' => 'First Option']
208-
]);
208+
]));
209209

210210
$this->collection->onAssembleGroup(function ($group, $addElement, $removeElement) {
211211
$group->setDefaultElementDecorator(new DivDecorator());
212212
$group->addElement($addElement);
213213

214214
$inner = new Collection('innerCollection');
215215
$inner->setLabel('Inner Collection');
216-
$inner->setAddElement('submitButton', 'inner_add_trigger', [
216+
$inner->setAddElement(new SubmitButtonElement('inner_add_trigger', [
217217
'label' => 'Inner Add Trigger'
218-
]);
218+
]));
219219
$inner->onAssembleGroup(function ($innerGroup, $innerAddElement, $innerRemoveElement) {
220220
$innerGroup->addElement($innerAddElement);
221221
$innerGroup->addElement('input', 'test_input');

0 commit comments

Comments
 (0)