diff --git a/app/bundles/FormBundle/Form/Type/FormType.php b/app/bundles/FormBundle/Form/Type/FormType.php index 15a9d547698..bbd625bd982 100644 --- a/app/bundles/FormBundle/Form/Type/FormType.php +++ b/app/bundles/FormBundle/Form/Type/FormType.php @@ -152,7 +152,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('renderStyle', YesNoButtonGroupType::class, [ 'label' => 'mautic.form.form.renderstyle', 'data' => (null === $options['data']->getRenderStyle()) ? true : $options['data']->getRenderStyle(), - 'empty_data' => true, 'attr' => [ 'tooltip' => 'mautic.form.form.renderstyle.tooltip', ], diff --git a/app/bundles/FormBundle/Tests/Controller/FormControllerFunctionalTest.php b/app/bundles/FormBundle/Tests/Controller/FormControllerFunctionalTest.php index 091a0209324..bc9d118ac51 100644 --- a/app/bundles/FormBundle/Tests/Controller/FormControllerFunctionalTest.php +++ b/app/bundles/FormBundle/Tests/Controller/FormControllerFunctionalTest.php @@ -3,7 +3,6 @@ namespace Mautic\FormBundle\Tests\Controller; use Mautic\CoreBundle\Test\MauticMysqlTestCase; -use Symfony\Component\HttpFoundation\Response; class FormControllerFunctionalTest extends MauticMysqlTestCase { @@ -13,8 +12,7 @@ class FormControllerFunctionalTest extends MauticMysqlTestCase public function testIndexActionWhenNotFiltered(): void { $this->client->request('GET', '/s/forms'); - $clientResponse = $this->client->getResponse(); - $this->assertSame(200, $clientResponse->getStatusCode(), 'Return code must be 200.'); + $this->assertTrue($this->client->getResponse()->isOk()); } /** @@ -23,8 +21,7 @@ public function testIndexActionWhenNotFiltered(): void public function testIndexActionWhenFiltering(): void { $this->client->request('GET', '/s/forms?search=has%3Aresults&tmpl=list'); - $clientResponse = $this->client->getResponse(); - $this->assertSame(200, $clientResponse->getStatusCode(), 'Return code must be 200.'); + $this->assertTrue($this->client->getResponse()->isOk()); } /** @@ -33,8 +30,37 @@ public function testIndexActionWhenFiltering(): void public function testNewActionForm(): void { $this->client->request('GET', '/s/forms/new/'); - $clientResponse = $this->client->getResponse(); - $clientResponseContent = $clientResponse->getContent(); - $this->assertEquals(Response::HTTP_OK, $clientResponse->getStatusCode()); + $this->assertTrue($this->client->getResponse()->isOk()); + } + + /** + * @see https://github.com/mautic/mautic/issues/10453 + */ + public function testSaveActionForm(): void + { + $crawler = $this->client->request('GET', '/s/forms/new/'); + $this->assertTrue($this->client->getResponse()->isOk()); + + $form = $crawler->filterXPath('//form[@name="mauticform"]')->form(); + $form->setValues( + [ + 'mauticform[name]' => 'Test', + 'mauticform[renderStyle]' => '', + ] + ); + $crawler = $this->client->submit($form); + $this->assertTrue($this->client->getResponse()->isOk()); + + $form = $crawler->filterXPath('//form[@name="mauticform"]')->form(); + $form->setValues( + [ + 'mauticform[renderStyle]' => '', + ] + ); + + // The form failed to save when saved for the second time with renderStyle=No. + $this->client->submit($form); + $this->assertTrue($this->client->getResponse()->isOk(), $this->client->getResponse()->getContent()); + $this->assertStringNotContainsString('Internal Server Error - Expected argument of type "null or string", "boolean" given', $this->client->getResponse()->getContent()); } }