EasyCorp/EasyAdminBundle

Submitting forms in Functional Tests results in errors

KDederichs opened this issue · 1 comments

Describe the bug
When submitting an EA form in functional tests it seems to miss the 'ea' parameter, causing it to error out.

To Reproduce

        $crawler = $this->client->request('GET', $this->generateEditFormUrl($foo->getId()));
        self::assertResponseIsSuccessful();
        $form = $crawler->filter($this->getEntityFormSelector())->form();
        $form->setValues([
            'Foo[bar]' => 'baz'
        ]);
        $crawler = $this->client->submit($form);

(OPTIONAL) Additional context
This will cause this error:

Caused by
ErrorException: Undefined array key "ea" in /app/vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:630
Stack trace:
#0 /app/vendor/symfony/framework-bundle/Test/BrowserKitAssertionsTrait.php(33): Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertThatForResponse(Object(Symfony\Component\HttpFoundation\Test\Constraint\ResponseIsSuccessful), '')
#1 /app/tests/Functional/Admin/Crud/ProjectCrudControllerTest.php(57): Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertResponseIsSuccessful()
#2 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/Framework/TestCase.php(1549): App\Tests\Functional\Admin\Crud\ProjectCrudControllerTest->testEditingCreditsUpdatesCache()
#3 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/Framework/TestCase.php(1155): PHPUnit\Framework\TestCase->runTest()
#4 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/Framework/TestResult.php(728): PHPUnit\Framework\TestCase->runBare()
#5 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/Framework/TestCase.php(905): PHPUnit\Framework\TestResult->run(Object(App\Tests\Functional\Admin\Crud\ProjectCrudControllerTest))
#6 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/Framework/TestSuite.php(675): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#7 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/TextUI/TestRunner.php(653): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#8 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/TextUI/Command.php(144): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#9 /app/vendor/bin/.phpunit/phpunit-9.5-0/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run(Array, true)
#10 /app/vendor/bin/.phpunit/phpunit-9.5-0/phpunit(22): PHPUnit\TextUI\Command::main()
#11 /app/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php(465): include('/app/vendor/bin...')
#12 /app/bin/phpunit(18): require('/app/vendor/sym...')
#13 {main}

Maybe that's just the wrong way to submit these forms for testing? The docs are not clear at all on that sadly.

It also seems to be impossible to add this parameter, since the Symfony form checks if the parameter exists on the form and is then throwing an error when trying to assign it.