/** * Go to the previous form page * * @param \Symfony\Component\DomCrawler\Form $form * @return \Neos\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); }
/** * Sets up a virtual browser and web environment for seamless HTTP and MVC * related tests. * * @return void */ protected function setupHttp() { $this->browser = new \Neos\Flow\Http\Client\Browser(); $this->browser->setRequestEngine(new \Neos\Flow\Http\Client\InternalRequestEngine()); $this->router = $this->browser->getRequestEngine()->getRouter(); $this->router->setRoutesConfiguration(null); $requestHandler = self::$bootstrap->getActiveRequestHandler(); $request = Request::create(new \Neos\Flow\Http\Uri('http://localhost/typo3/flow/test')); $componentContext = new ComponentContext($request, new \Neos\Flow\Http\Response()); $requestHandler->setComponentContext($componentContext); }
/** * @test * @expectedException \Neos\Flow\Http\Client\InfiniteRedirectionException */ public function browserHaltsOnExceedingMaximumRedirections() { $requestEngine = $this->createMock(Client\RequestEngineInterface::class); for ($i = 0; $i <= 10; $i++) { $response = new Http\Response(); $response->setHeader('Location', 'http://localhost/this/willLead/you/knowhere/' . $i); $response->setStatus(301); $requestEngine->expects($this->at($i))->method('sendRequest')->will($this->returnValue($response)); } $this->browser->setRequestEngine($requestEngine); $this->browser->request('http://localhost/some/initialRequest'); }
/** * @test */ public function valueForDisabledCheckboxIsNotLost() { $postIdentifier = $this->setupDummyPost(); $post = $this->persistenceManager->getObjectByIdentifier($postIdentifier, \Neos\FluidAdaptor\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, \Neos\FluidAdaptor\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!'); }