Skip to content

Commit

Permalink
MERGE: Merge branch '2.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns committed Jun 15, 2016
2 parents 590be87 + 04e14c7 commit 25d0869
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Tests/Unit/Core/Renderer/FormRuntimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
* */

use TYPO3\Form\Core\Model\FormDefinition;
use TYPO3\Form\Core\Runtime\FormRuntime;
use TYPO3\Form\Core\Model\Page;

require_once(__DIR__ . '/Fixture/DummyFinisher.php');

/**
* Test for Form Runtime
*
* @covers \TYPO3\Form\Core\Runtime\FormRuntime<extended>
*/
class FormRuntimeTest extends \TYPO3\Flow\Tests\UnitTestCase
Expand All @@ -31,7 +32,7 @@ public function valuesSetInConstructorCanBeReadAgain()
$mockActionRequest = $this->getMockBuilder('TYPO3\Flow\Mvc\ActionRequest')->disableOriginalConstructor()->getMock();
$mockHttpResponse = $this->getMockBuilder('TYPO3\Flow\Http\Response')->disableOriginalConstructor()->getMock();

$formRuntime = $this->createFormRuntime($formDefinition, $mockActionRequest, $mockHttpResponse);
$formRuntime = $this->getAccessibleMock('TYPO3\Form\Core\Runtime\FormRuntime', ['dummy'], [$formDefinition, $mockActionRequest, $mockHttpResponse]);

$this->assertSame($mockActionRequest, $formRuntime->getRequest()->getParentRequest());
$this->assertSame($mockHttpResponse, $formRuntime->getResponse());
Expand Down Expand Up @@ -66,7 +67,7 @@ public function getRenderingOptionsReturnsRenderingOptionsOfFormDefinition()
$formDefinition = new FormDefinition('foo');
$formDefinition->setRenderingOption('asdf', 'test');
$formRuntime = $this->createFormRuntime($formDefinition);
$this->assertSame(array('asdf' => 'test'), $formRuntime->getRenderingOptions());
$this->assertSame(['asdf' => 'test'], $formRuntime->getRenderingOptions());
}

/**
Expand Down Expand Up @@ -98,7 +99,7 @@ public function invokeFinishersInvokesFinishersInCorrectOrder()
{
$formDefinition = new FormDefinition('foo');

$finisherCalls = array();
$finisherCalls = [];

$finisher1 = $this->getMockFinisher(function () use (&$finisherCalls) {
$finisherCalls[] = func_get_args();
Expand Down Expand Up @@ -129,6 +130,7 @@ protected function getMockFinisher(\Closure $closureToExecute)
{
$finisher = new Renderer\Fixture\DummyFinisher();
$finisher->cb = $closureToExecute;

return $finisher;
}

Expand All @@ -146,7 +148,7 @@ public function pageNavigationWorks()
$formDefinition->addPage($page3);

$formRuntime = $this->createFormRuntime($formDefinition);
$this->assertSame(array($page1, $page2, $page3), $formRuntime->getPages());
$this->assertSame([$page1, $page2, $page3], $formRuntime->getPages());

$formRuntime->overrideCurrentPage(0);
$this->assertSame(null, $formRuntime->getPreviousPage());
Expand Down Expand Up @@ -198,19 +200,13 @@ public function arrayAccessReturnsDefaultValuesIfSet()

/**
* @param FormDefinition $formDefinition
* @param \TYPO3\Flow\Mvc\ActionRequest $request
* @param \TYPO3\Flow\Http\Response $response
* @return \TYPO3\Form\Core\Runtime\FormRuntime
*/
protected function createFormRuntime(FormDefinition $formDefinition, \TYPO3\Flow\Mvc\ActionRequest $request = null, \TYPO3\Flow\Http\Response $response = null)
protected function createFormRuntime(FormDefinition $formDefinition)
{
if ($request === null) {
$httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('foo'));
$request = $httpRequest->createActionRequest();
}
if ($response === null) {
$response = new \TYPO3\Flow\Http\Response();
}
return $this->getAccessibleMock('TYPO3\Form\Core\Runtime\FormRuntime', array('dummy'), array($formDefinition, $request, $response));
$mockActionRequest = $this->getMockBuilder('TYPO3\Flow\Mvc\ActionRequest')->disableOriginalConstructor()->getMock();
$mockHttpResponse = $this->getMockBuilder('TYPO3\Flow\Http\Response')->disableOriginalConstructor()->getMock();

return $this->getAccessibleMock('TYPO3\Form\Core\Runtime\FormRuntime', ['dummy'], [$formDefinition, $mockActionRequest, $mockHttpResponse]);
}
}

0 comments on commit 25d0869

Please sign in to comment.