[Form] Fixed failing FormDataExtractorTest

This commit is contained in:
Bernhard Schussek 2013-10-30 13:42:39 +01:00
parent 23f12faa53
commit 4807c5effc
2 changed files with 10 additions and 3 deletions

View File

@ -123,9 +123,13 @@ class FormDataExtractor implements FormDataExtractorInterface
*/ */
public function extractViewVariables(FormView $view) public function extractViewVariables(FormView $view)
{ {
$data = array( $data = array();
'id' => $view->vars['id']
); // Set the ID in case no FormInterface object was collected for this
// view
if (isset($view->vars['id'])) {
$data['id'] = $view->vars['id'];
}
foreach ($view->vars as $varName => $value) { foreach ($view->vars as $varName => $value) {
$data['view_vars'][$varName] = $this->valueExporter->exportValue($value); $data['view_vars'][$varName] = $this->valueExporter->exportValue($value);

View File

@ -352,13 +352,16 @@ class FormDataExtractorTest extends \PHPUnit_Framework_TestCase
'b' => 'foo', 'b' => 'foo',
'a' => 'bar', 'a' => 'bar',
'c' => 'baz', 'c' => 'baz',
'id' => 'foo_bar',
); );
$this->assertSame(array( $this->assertSame(array(
'id' => 'foo_bar',
'view_vars' => array( 'view_vars' => array(
'a' => "'bar'", 'a' => "'bar'",
'b' => "'foo'", 'b' => "'foo'",
'c' => "'baz'", 'c' => "'baz'",
'id' => "'foo_bar'",
), ),
), $this->dataExtractor->extractViewVariables($view)); ), $this->dataExtractor->extractViewVariables($view));
} }