Skip to content

Commit

Permalink
Revert unneeded changes from "Fixes for nested multipliers (#59)"
Browse files Browse the repository at this point in the history
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.

- Latte 2 macros are trivial to migrate and unclearly named, no need to keep them for BC.
- The onSuccess handlers were already fixed in ed96ba0.
- `testGroupManualRenderWithButtons` look like remnants of debugging effort, they do not fix the test.

For reference, the reverted change is the following commit that was squashed
into 39725d3, except for the change to `testSendNested`:
2c33de2
  • Loading branch information
jtojnar committed May 14, 2024
1 parent bfe52eb commit 4f1fec9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 42 deletions.
2 changes: 0 additions & 2 deletions src/Latte/Extension/MultiplierExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function getTags(): array
'n:multiplier' => [MultiplierNode::class, 'create'],
'multiplier:remove' => [MultiplierRemoveNode::class, 'create'],
'multiplier:add' => [MultiplierAddNode::class, 'create'],
'btnRemove' => [MultiplierRemoveNode::class, 'create'],
'btnCreate' => [MultiplierAddNode::class, 'create'],
];
}

Expand Down
6 changes: 1 addition & 5 deletions tests/Unit/CreateButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ public function testCallback()
$submitter->setHtmlAttribute('class', 'add-btn');
});

$response = $this->services->form->createRequest($factory
->formModifier(function (\Nette\Application\UI\Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})->createForm())->setPost([
$response = $this->services->form->createRequest($factory->createForm())->setPost([
'm' => [
['bar' => ''],
['bar' => ''],
Expand Down
25 changes: 2 additions & 23 deletions tests/Unit/MultiplierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public function testSendBase()
$this->parameters['onCreate'][] = $container;
};
})
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)
->setPost($params = [
Expand Down Expand Up @@ -102,10 +98,6 @@ public function testSendCopy2()
$this->parameters['onCreate'][] = $container;
};
})
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)
->setPost($params = [
Expand Down Expand Up @@ -156,10 +148,6 @@ public function testSendMaxCopy()
$this->parameters['onCreate'][] = $container;
};
})
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)
->setPost([
Expand Down Expand Up @@ -226,10 +214,6 @@ public function testSendNested()
}));
$container['m2']->addCreateButton('create');
})
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
);
$request->setPost([
Expand Down Expand Up @@ -396,15 +380,14 @@ public function testGroupManualRenderWithButtons()
->multiplierModifier(function (Multiplier $multiplier) {
$multiplier->onCreate[] = function (Container $container) {
$this->parameters['onCreate'][] = $container;
$container->setParent(null, 'X');
//var_dump($container);
};
$multiplier->addCreateButton();
$multiplier->addRemoveButton();
//$multiplier->setMinCopies(1);
$multiplier->setMinCopies(1);
})
->createForm());
$dom = $request->render(__DIR__ . '/templates/group.latte')->toDomQuery();

$this->assertDomHas($dom, 'input[name="m[0][multiplier_remover]"]');
$this->assertDomHas($dom, 'input[name="m[1][multiplier_remover]"]');
}
Expand Down Expand Up @@ -473,10 +456,6 @@ public function testPromptSelect()
->setPrompt('Select');
})
->addCreateButton()
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)
->setPost($params = [
Expand Down
12 changes: 0 additions & 12 deletions tests/Unit/RemoveButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ public function testAddClass()
$submitter->setHtmlAttribute('class', 'btn btn-remove');
})
->addCreateButton()
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)->setPost([
'm' => [
Expand All @@ -219,10 +215,6 @@ public function testDeleteLastElementToZero()
->setMinCopies(0)
->addRemoveButton()
->addCreateButton()
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)->modifyForm(function (Form $form) {
$form['m']->setValues([
Expand Down Expand Up @@ -252,10 +244,6 @@ public function testOnRemoveEvent()
$called = true;
};
})
->formModifier(function (Form $form) {
$form->onSuccess[] = $form->onError[] = $form->onSubmit[] = function () {
};
})
->createForm()
)->setPost([
'm' => [
Expand Down

0 comments on commit 4f1fec9

Please sign in to comment.