This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11066).
Discussion
----------
#10808 crawler test
Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |#10808
| License | MIT
Adds test for #10808
Commits
-------
876d6ca
issue #10808 crawler test
This commit is contained in:
commit
fddd010e49
@ -146,7 +146,7 @@ class Form extends Link implements \ArrayAccess
|
|||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->getValues() as $name => $value) {
|
foreach ($this->getValues() as $name => $value) {
|
||||||
$qs = http_build_query(array($name => $value), '', '&');
|
$qs = http_build_query(array($name => $value), '', '&');
|
||||||
if(!empty($qs)) {
|
if (!empty($qs)) {
|
||||||
parse_str($qs, $expandedValue);
|
parse_str($qs, $expandedValue);
|
||||||
$varName = substr($name, 0, strlen(key($expandedValue)));
|
$varName = substr($name, 0, strlen(key($expandedValue)));
|
||||||
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
||||||
@ -171,7 +171,7 @@ class Form extends Link implements \ArrayAccess
|
|||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->getFiles() as $name => $value) {
|
foreach ($this->getFiles() as $name => $value) {
|
||||||
$qs = http_build_query(array($name => $value), '', '&');
|
$qs = http_build_query(array($name => $value), '', '&');
|
||||||
if(!empty($qs)) {
|
if (!empty($qs)) {
|
||||||
parse_str($qs, $expandedValue);
|
parse_str($qs, $expandedValue);
|
||||||
$varName = substr($name, 0, strlen(key($expandedValue)));
|
$varName = substr($name, 0, strlen(key($expandedValue)));
|
||||||
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
|
||||||
|
@ -374,8 +374,8 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetValues()
|
public function testGetValues()
|
||||||
{
|
{
|
||||||
$form = $this->createForm('<form><input type="text" name="foo[bar]" value="foo" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
|
$form = $this->createForm('<form><input type="text" name="foo[bar]" value="foo" /><input type="text" name="bar" value="bar" /><select multiple="multiple" name="baz[]"></select><input type="submit" /></form>');
|
||||||
$this->assertEquals(array('foo[bar]' => 'foo', 'bar' => 'bar'), $form->getValues(), '->getValues() returns all form field values');
|
$this->assertEquals(array('foo[bar]' => 'foo', 'bar' => 'bar', 'baz' => array()), $form->getValues(), '->getValues() returns all form field values');
|
||||||
|
|
||||||
$form = $this->createForm('<form><input type="checkbox" name="foo" value="foo" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
|
$form = $this->createForm('<form><input type="checkbox" name="foo" value="foo" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
|
||||||
$this->assertEquals(array('bar' => 'bar'), $form->getValues(), '->getValues() does not include not-checked checkboxes');
|
$this->assertEquals(array('bar' => 'bar'), $form->getValues(), '->getValues() does not include not-checked checkboxes');
|
||||||
@ -411,6 +411,10 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$form = $this->createForm('<form><input type="text" name="fo.o[ba.r][]" value="foo" /><input type="text" name="fo.o[ba.r][ba.z]" value="bar" /><input type="submit" /></form>');
|
$form = $this->createForm('<form><input type="text" name="fo.o[ba.r][]" value="foo" /><input type="text" name="fo.o[ba.r][ba.z]" value="bar" /><input type="submit" /></form>');
|
||||||
$this->assertEquals(array('fo.o' => array('ba.r' => array('foo', 'ba.z' => 'bar'))), $form->getPhpValues(), '->getPhpValues() preserves periods and spaces in names recursively');
|
$this->assertEquals(array('fo.o' => array('ba.r' => array('foo', 'ba.z' => 'bar'))), $form->getPhpValues(), '->getPhpValues() preserves periods and spaces in names recursively');
|
||||||
|
|
||||||
|
$form = $this->createForm('<form><input type="text" name="foo[bar]" value="foo" /><input type="text" name="bar" value="bar" /><select multiple="multiple" name="baz[]"></select><input type="submit" /></form>');
|
||||||
|
$this->assertEquals(array('foo' => array('bar' => 'foo'), 'bar' => 'bar'), $form->getPhpValues(), "->getPhpValues() doesn't return empty values");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFiles()
|
public function testGetFiles()
|
||||||
|
Reference in New Issue
Block a user