/** * Go to the previous form page * * @param \Symfony\Component\DomCrawler\Form $form * @return \TYPO3\Flow\Http\Response */ protected function gotoPreviousFormPage(\Symfony\Component\DomCrawler\Form $form) { $previousButton = $this->browser->getCrawler()->filterXPath('//nav[@class="form-navigation"]/*/*[contains(@class, "previous")]/button'); $previousButton->rewind(); $form->set(new InputFormField($previousButton->current())); return $this->browser->submit($form); }
/** * @test */ public function formIsRedisplayedIfValidationErrorsOccur() { $this->browser->request('http://localhost/test/fluid/formobjects'); $form = $this->browser->getForm(); $form['post']['name']->setValue('Egon Olsen'); $form['post']['email']->setValue('test_noValidEmail'); $this->browser->submit($form); $form = $this->browser->getForm(); $this->assertSame('Egon Olsen', $form['post']['name']->getValue()); $this->assertSame('test_noValidEmail', $form['post']['email']->getValue()); $this->assertSame('f3-form-error', $this->browser->getCrawler()->filterXPath('//*[@id="email"]')->attr('class')); $form['post']['email']->setValue('*****@*****.**'); $response = $this->browser->submit($form); $this->assertSame('Egon Olsen|another@email.org', $response->getContent()); }
/** * @test */ public function valueForDisabledCheckboxIsNotLost() { $postIdentifier = $this->setupDummyPost(); $post = $this->persistenceManager->getObjectByIdentifier($postIdentifier, \TYPO3\Fluid\Tests\Functional\Form\Fixtures\Domain\Model\Post::class); $this->assertEquals(true, $post->getPrivate()); $this->browser->request('http://localhost/test/fluid/formobjects/edit?fooPost=' . $postIdentifier); $checkboxDisabled = $this->browser->getCrawler()->filterXPath('//*[@id="private"]')->attr('disabled'); $this->assertNotEmpty($checkboxDisabled); $this->assertEquals($checkboxDisabled, $this->browser->getCrawler()->filterXPath('//input[@type="hidden" and contains(@name,"private")]')->attr('disabled'), 'The hidden checkbox field is not disabled like the connected checkbox.'); $form = $this->browser->getForm(); $this->browser->submit($form); $this->persistenceManager->clearState(); $post = $this->persistenceManager->getObjectByIdentifier($postIdentifier, \TYPO3\Fluid\Tests\Functional\Form\Fixtures\Domain\Model\Post::class); // This will currently never fail, because DomCrawler\Form does not handle hidden checkbox fields correctly! // Hence this test currently only relies on the correctly set "disabled" attribute on the hidden field. $this->assertEquals(true, $post->getPrivate(), 'The value for the checkbox field "private" was lost on form submit!'); }
/** * @test */ public function radioButtonsAreCheckedCorrectlyOnValidationErrors() { $this->browser->request('http://localhost/test/fluid/formobjects'); $form = $this->browser->getForm(); $form['post']['author']['emailAddress']->setValue('test_noValidEmail'); $form['post']['category']->setValue('bar'); $form['post']['subCategory']->setValue('bar'); $this->browser->submit($form); $this->assertEquals('', $this->browser->getCrawler()->filterXPath('//input[@id="category_foo"]')->attr('checked')); $this->assertEquals('checked', $this->browser->getCrawler()->filterXPath('//input[@id="category_bar"]')->attr('checked')); $this->assertEquals('', $this->browser->getCrawler()->filterXPath('//input[@id="subCategory_foo"]')->attr('checked')); $this->assertEquals('checked', $this->browser->getCrawler()->filterXPath('//input[@id="subCategory_bar"]')->attr('checked')); $form['post']['category']->setValue('foo'); $form['post']['subCategory']->setValue('foo'); $this->browser->submit($form); $this->assertEquals('checked', $this->browser->getCrawler()->filterXPath('//input[@id="category_foo"]')->attr('checked')); $this->assertEquals('', $this->browser->getCrawler()->filterXPath('//input[@id="category_bar"]')->attr('checked')); $this->assertEquals('checked', $this->browser->getCrawler()->filterXPath('//input[@id="subCategory_foo"]')->attr('checked')); $this->assertEquals('', $this->browser->getCrawler()->filterXPath('//input[@id="subCategory_bar"]')->attr('checked')); }