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.

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 Feb 18, 2024
1 parent 9b4e600 commit 738cb9a
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 @@ -89,11 +89,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 @@ -44,10 +44,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 @@ -97,10 +93,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 @@ -151,10 +143,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 @@ -221,10 +209,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 @@ -319,15 +303,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 @@ -396,10 +379,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 @@ -188,10 +188,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 @@ -214,10 +210,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 @@ -247,10 +239,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 738cb9a

Please sign in to comment.