public function FormTest::testMultiValuedFields in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Tests/FormTest.php \Symfony\Component\DomCrawler\Tests\FormTest::testMultiValuedFields()
File
- vendor/
symfony/ dom-crawler/ Tests/ FormTest.php, line 149
Class
Namespace
Symfony\Component\DomCrawler\TestsCode
public function testMultiValuedFields() {
$form = $this
->createForm('<form>
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
<input type="text" name="foo" value="foo" disabled="disabled" />
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
<input type="text" name="foo[]" value="foo" disabled="disabled" />
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
<input type="submit" />
</form>
');
$this
->assertEquals(array_keys($form
->all()), array(
'foo[2]',
'foo[3]',
'bar[foo][0]',
'bar[foo][foobar]',
));
$this
->assertEquals($form
->get('foo[2]')
->getValue(), 'foo');
$this
->assertEquals($form
->get('foo[3]')
->getValue(), 'foo');
$this
->assertEquals($form
->get('bar[foo][0]')
->getValue(), 'foo');
$this
->assertEquals($form
->get('bar[foo][foobar]')
->getValue(), 'foo');
$form['foo[2]'] = 'bar';
$form['foo[3]'] = 'bar';
$this
->assertEquals($form
->get('foo[2]')
->getValue(), 'bar');
$this
->assertEquals($form
->get('foo[3]')
->getValue(), 'bar');
$form['bar'] = array(
'foo' => array(
'0' => 'bar',
'foobar' => 'foobar',
),
);
$this
->assertEquals($form
->get('bar[foo][0]')
->getValue(), 'bar');
$this
->assertEquals($form
->get('bar[foo][foobar]')
->getValue(), 'foobar');
}