Skip to content

Commit

Permalink
tests: Demonstrate orphan fieldsets (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtojnar authored Nov 21, 2023
1 parent 387a2cd commit a2ccdcf
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/unit/CreateButtonTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use Nette\Application\UI\Form;
use Nette\Forms\Container;
use Nette\Forms\Controls\SubmitButton;
use Contributte\FormMultiplier\Multiplier;
use Contributte\FormMultiplier\Submitter;

class CreateButtonTest extends \Codeception\TestCase\Test
Expand Down Expand Up @@ -132,4 +135,30 @@ public function testFormEvents()
$this->assertTrue($called);
}

public function testNoOrphanFieldsets()
{
$i = 1;
$form = new Form();
$form['members'] = $membersMultiplier = new Multiplier(function (Container $container) use ($form, &$i) {
$group = $form->addGroup('Team member #' . $i++);
$container->setCurrentGroup($group);
$container->addText('name', 'Name');
});
$form->setCurrentGroup(null);
$membersMultiplier->addCreateButton('add');

$req = $this->services->form->createRequest($form);
$response = $req->setPost([
'members' => [
[],
'multiplier_creator' => '',
],
])->send();

$dom = $response->toDomQuery();
codecept_debug($response->toString());

$this->assertCount(2, $dom->find('fieldset'), 'After adding a container, there should be two fieldsets.');
}

}

0 comments on commit a2ccdcf

Please sign in to comment.