From 876d6caacb4e1164b21468e8978263b40dd259b2 Mon Sep 17 00:00:00 2001 From: Michal Dabrowski Date: Fri, 6 Jun 2014 07:02:13 +0200 Subject: [PATCH] issue #10808 crawler test --- src/Symfony/Component/DomCrawler/Form.php | 4 ++-- src/Symfony/Component/DomCrawler/Tests/FormTest.php | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 717e426c1e..0a60fac5ef 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -146,7 +146,7 @@ class Form extends Link implements \ArrayAccess $values = array(); foreach ($this->getValues() as $name => $value) { $qs = http_build_query(array($name => $value), '', '&'); - if(!empty($qs)) { + if (!empty($qs)) { parse_str($qs, $expandedValue); $varName = substr($name, 0, strlen(key($expandedValue))); $values = array_replace_recursive($values, array($varName => current($expandedValue))); @@ -171,7 +171,7 @@ class Form extends Link implements \ArrayAccess $values = array(); foreach ($this->getFiles() as $name => $value) { $qs = http_build_query(array($name => $value), '', '&'); - if(!empty($qs)) { + if (!empty($qs)) { parse_str($qs, $expandedValue); $varName = substr($name, 0, strlen(key($expandedValue))); $values = array_replace_recursive($values, array($varName => current($expandedValue))); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 0c12b08dc8..092db68561 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -374,8 +374,8 @@ class FormTest extends \PHPUnit_Framework_TestCase public function testGetValues() { - $form = $this->createForm('
'); - $this->assertEquals(array('foo[bar]' => 'foo', 'bar' => 'bar'), $form->getValues(), '->getValues() returns all form field values'); + $form = $this->createForm('
'); + $this->assertEquals(array('foo[bar]' => 'foo', 'bar' => 'bar', 'baz' => array()), $form->getValues(), '->getValues() returns all form field values'); $form = $this->createForm('
'); $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('
'); $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('
'); + $this->assertEquals(array('foo' => array('bar' => 'foo'), 'bar' => 'bar'), $form->getPhpValues(), "->getPhpValues() doesn't return empty values"); + } public function testGetFiles()