Skip to content

Commit

Permalink
[DomCrawler] Add tests for recursive cases of getPhpValues() and getP…
Browse files Browse the repository at this point in the history
…hpFiles()
  • Loading branch information
romainneutron committed Mar 13, 2014
1 parent e961f57 commit 89c599e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Symfony/Component/DomCrawler/Form.php
Expand Up @@ -408,8 +408,7 @@ private function initialize()

// restore the original name of the input node
$this->button->setAttribute('name', $name);
}
else {
} else {
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/DomCrawler/Tests/FormTest.php
Expand Up @@ -394,6 +394,9 @@ public function testGetPhpValues()

$form = $this->createForm('<form><input type="text" name="fo.o[ba.r]" value="foo" /><input type="text" name="ba r" value="bar" /><input type="submit" /></form>');
$this->assertEquals(array('fo.o' => array('ba.r' => 'foo'), 'ba r' => 'bar'), $form->getPhpValues(), '->getPhpValues() preserves periods and spaces in names');

$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');
}

public function testGetFiles()
Expand Down Expand Up @@ -424,6 +427,9 @@ public function testGetPhpFiles()

$form = $this->createForm('<form method="post"><input type="file" name="f.o o[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
$this->assertEquals(array('f.o o' => array('bar' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0))), $form->getPhpFiles(), '->getPhpFiles() preserves periods and spaces in names');

$form = $this->createForm('<form method="post"><input type="file" name="f.o o[bar][ba.z]" /><input type="file" name="f.o o[bar][]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
$this->assertEquals(array('f.o o' => array('bar' => array('ba.z' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0), array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)))), $form->getPhpFiles(), '->getPhpFiles() preserves periods and spaces in names recursively');
}

/**
Expand Down

0 comments on commit 89c599e

Please sign in to comment.