Skip to content

Commit 738cb9a

Browse files
committed
Revert unneeded changes from "Fixes for nested multipliers (#59)"
This partially reverts commit 39725d3, only keeping the part relevant for nested support and a PHPUnit deprecation fix. The commit introduced a regression in `testGroupManualRenderWithButtons` so this will minimize the changes that could affect it. For reference, the reverted change is the following commit that was squashed into 39725d3, except for the change to `testSendNested`: 2c33de2
1 parent 9b4e600 commit 738cb9a

File tree

4 files changed

+3
-42
lines changed

4 files changed

+3
-42
lines changed

src/Latte/Extension/MultiplierExtension.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public function getTags(): array
2020
'n:multiplier' => [MultiplierNode::class, 'create'],
2121
'multiplier:remove' => [MultiplierRemoveNode::class, 'create'],
2222
'multiplier:add' => [MultiplierAddNode::class, 'create'],
23-
'btnRemove' => [MultiplierRemoveNode::class, 'create'],
24-
'btnCreate' => [MultiplierAddNode::class, 'create'],
2523
];
2624
}
2725

tests/unit/CreateButtonTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ public function testCallback()
8989
$submitter->setHtmlAttribute('class', 'add-btn');
9090
});
9191

92-
$response = $this->services->form->createRequest($factory
93-
->formModifier(function (\Nette\Application\UI\Form $form) {
94-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
95-
};
96-
})->createForm())->setPost([
92+
$response = $this->services->form->createRequest($factory->createForm())->setPost([
9793
'm' => [
9894
['bar' => ''],
9995
['bar' => ''],

tests/unit/MultiplierTest.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ public function testSendBase()
4444
$this->parameters['onCreate'][] = $container;
4545
};
4646
})
47-
->formModifier(function (Form $form) {
48-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
49-
};
50-
})
5147
->createForm()
5248
)
5349
->setPost($params = [
@@ -97,10 +93,6 @@ public function testSendCopy2()
9793
$this->parameters['onCreate'][] = $container;
9894
};
9995
})
100-
->formModifier(function (Form $form) {
101-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
102-
};
103-
})
10496
->createForm()
10597
)
10698
->setPost($params = [
@@ -151,10 +143,6 @@ public function testSendMaxCopy()
151143
$this->parameters['onCreate'][] = $container;
152144
};
153145
})
154-
->formModifier(function (Form $form) {
155-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
156-
};
157-
})
158146
->createForm()
159147
)
160148
->setPost([
@@ -221,10 +209,6 @@ public function testSendNested()
221209
}));
222210
$container['m2']->addCreateButton('create');
223211
})
224-
->formModifier(function (Form $form) {
225-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
226-
};
227-
})
228212
->createForm()
229213
);
230214
$request->setPost([
@@ -319,15 +303,14 @@ public function testGroupManualRenderWithButtons()
319303
->multiplierModifier(function (Multiplier $multiplier) {
320304
$multiplier->onCreate[] = function (Container $container) {
321305
$this->parameters['onCreate'][] = $container;
322-
$container->setParent(null, 'X');
323-
//var_dump($container);
324306
};
325307
$multiplier->addCreateButton();
326308
$multiplier->addRemoveButton();
327-
//$multiplier->setMinCopies(1);
309+
$multiplier->setMinCopies(1);
328310
})
329311
->createForm());
330312
$dom = $request->render(__DIR__ . '/templates/group.latte')->toDomQuery();
313+
331314
$this->assertDomHas($dom, 'input[name="m[0][multiplier_remover]"]');
332315
$this->assertDomHas($dom, 'input[name="m[1][multiplier_remover]"]');
333316
}
@@ -396,10 +379,6 @@ public function testPromptSelect()
396379
->setPrompt('Select');
397380
})
398381
->addCreateButton()
399-
->formModifier(function (Form $form) {
400-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
401-
};
402-
})
403382
->createForm()
404383
)
405384
->setPost($params = [

tests/unit/RemoveButtonTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ public function testAddClass()
188188
$submitter->setHtmlAttribute('class', 'btn btn-remove');
189189
})
190190
->addCreateButton()
191-
->formModifier(function (Form $form) {
192-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
193-
};
194-
})
195191
->createForm()
196192
)->setPost([
197193
'm' => [
@@ -214,10 +210,6 @@ public function testDeleteLastElementToZero()
214210
->setMinCopies(0)
215211
->addRemoveButton()
216212
->addCreateButton()
217-
->formModifier(function (Form $form) {
218-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
219-
};
220-
})
221213
->createForm()
222214
)->modifyForm(function (Form $form) {
223215
$form['m']->setValues([
@@ -247,10 +239,6 @@ public function testOnRemoveEvent()
247239
$called = true;
248240
};
249241
})
250-
->formModifier(function (Form $form) {
251-
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
252-
};
253-
})
254242
->createForm()
255243
)->setPost([
256244
'm' => [

0 commit comments

Comments
 (0)