unit testing form
Hello,
I'm trying to unit test a form:
use Eckinox\TinymceBundle\Form\Type\TinymceType;
...
->add('description', TinymceType::class, [
'label' => 'label.description',
'required' => false,
]);
In my test i do:
$crawler = $this->client->request('GET', '/ ...');
$buttonCrawlerNode = $crawler->selectButton('Save');
$form = $buttonCrawlerNode->form();
In $form variable i have all the fields of the form except for 'description'. If I change it into a 'TextAreaType' it works fine, it's present in $form.
How do i get this field into my php unit test?
Thank you very much in advance.
With kind regards, Annemieke
Hi @annemiekebuijs,
I believe this occurs because the web client you use in your tests does not execute Javascript.
Web components, like the TinyMCE one that is used by this bundle, require Javascript to work, so the input is simply missing from the page when scripts are not executed.
I've just added a no script fallback for this in v3.1.1 of my fork (https://github.com/EmilePerron/tinymce-bundle) which I believe should fix this. It adds a textarea with the same input name inside of a <noscript> right after the TinyMCE web component, which provides an alternative input for the form when Javascript isn't executed.