You are here

public function FileFormFieldTest::testSetErrorCode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php \Symfony\Component\DomCrawler\Tests\Field\FileFormFieldTest::testSetErrorCode()

File

vendor/symfony/dom-crawler/Tests/Field/FileFormFieldTest.php, line 89

Class

FileFormFieldTest

Namespace

Symfony\Component\DomCrawler\Tests\Field

Code

public function testSetErrorCode() {
  $node = $this
    ->createNode('input', '', array(
    'type' => 'file',
  ));
  $field = new FileFormField($node);
  $field
    ->setErrorCode(UPLOAD_ERR_FORM_SIZE);
  $value = $field
    ->getValue();
  $this
    ->assertEquals(UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code');
  try {
    $field
      ->setErrorCode('foobar');
    $this
      ->fail('->setErrorCode() throws a \\InvalidArgumentException if the error code is not valid');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->setErrorCode() throws a \\InvalidArgumentException if the error code is not valid');
  }
}