You are here

public function FormTest::testGetFiles in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/dom-crawler/Tests/FormTest.php \Symfony\Component\DomCrawler\Tests\FormTest::testGetFiles()

File

vendor/symfony/dom-crawler/Tests/FormTest.php, line 439

Class

FormTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testGetFiles() {
  $form = $this
    ->createForm('<form><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
  $this
    ->assertEquals(array(), $form
    ->getFiles(), '->getFiles() returns an empty array if method is get');
  $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(array(
    'foo[bar]' => array(
      'name' => '',
      'type' => '',
      'tmp_name' => '',
      'error' => 4,
      'size' => 0,
    ),
  ), $form
    ->getFiles(), '->getFiles() only returns file fields for POST');
  $form = $this
    ->createForm('<form method="post"><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>', 'put');
  $this
    ->assertEquals(array(
    'foo[bar]' => array(
      'name' => '',
      'type' => '',
      'tmp_name' => '',
      'error' => 4,
      'size' => 0,
    ),
  ), $form
    ->getFiles(), '->getFiles() only returns file fields for PUT');
  $form = $this
    ->createForm('<form method="post"><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>', 'delete');
  $this
    ->assertEquals(array(
    'foo[bar]' => array(
      'name' => '',
      'type' => '',
      'tmp_name' => '',
      'error' => 4,
      'size' => 0,
    ),
  ), $form
    ->getFiles(), '->getFiles() only returns file fields for DELETE');
  $form = $this
    ->createForm('<form method="post"><input type="file" name="foo[bar]" /><input type="text" name="bar" value="bar" /><input type="submit" /></form>', 'patch');
  $this
    ->assertEquals(array(
    'foo[bar]' => array(
      'name' => '',
      'type' => '',
      'tmp_name' => '',
      'error' => 4,
      'size' => 0,
    ),
  ), $form
    ->getFiles(), '->getFiles() only returns file fields for PATCH');
  $form = $this
    ->createForm('<form method="post"><input type="file" name="foo[bar]" disabled="disabled" /><input type="submit" /></form>');
  $this
    ->assertEquals(array(), $form
    ->getFiles(), '->getFiles() does not include disabled file fields');
}