$form =
$this->
createForm('<form method="post"><input type="file" name="foo[bar]" disabled="disabled" /><input type="submit" /></form>'
);
$this->
assertEquals([],
$form->
getFiles(), '->getFiles() does not include disabled file fields'
);
$form =
$this->
createForm('<form method="post"><template><input type="file" name="foo"/></template><input type="text" name="bar" value="bar"/><input type="submit"/></form>'
);
$this->
assertEquals([],
$form->
getFiles(), '->getFiles() does not include template file fields'
);
$this->
assertFalse($form->
has('foo'
));
} public function testGetPhpFiles() { $form =
$this->
createForm('<form method="post"><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>'
);
$this->
assertEquals(['foo' =>
['bar' =>
['name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0
]]],
$form->
getPhpFiles(), '->getPhpFiles() converts keys with [] to arrays'
);
$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(['f.o o' =>
['bar' =>
['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(['f.o o' =>
['bar' =>
['ba.z' =>
['name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0
],
['name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0
]]]],
$form->
getPhpFiles(), '->getPhpFiles() preserves periods and spaces in names recursively'
);
$form =
$this->
createForm('<form method="post"><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>'
);
$files =
$form->
getPhpFiles();
$this->
assertSame(0,
$files['foo'
]['bar'
]['size'
], '->getPhpFiles() converts size to int'
);