You are here

public function FileFormFieldTest::testInitialize 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::testInitialize()

File

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

Class

FileFormFieldTest

Namespace

Symfony\Component\DomCrawler\Tests\Field

Code

public function testInitialize() {
  $node = $this
    ->createNode('input', '', array(
    'type' => 'file',
  ));
  $field = new FileFormField($node);
  $this
    ->assertEquals(array(
    'name' => '',
    'type' => '',
    'tmp_name' => '',
    'error' => UPLOAD_ERR_NO_FILE,
    'size' => 0,
  ), $field
    ->getValue(), '->initialize() sets the value of the field to no file uploaded');
  $node = $this
    ->createNode('textarea', '');
  try {
    $field = new FileFormField($node);
    $this
      ->fail('->initialize() throws a \\LogicException if the node is not an input field');
  } catch (\LogicException $e) {
    $this
      ->assertTrue(true, '->initialize() throws a \\LogicException if the node is not an input field');
  }
  $node = $this
    ->createNode('input', '', array(
    'type' => 'text',
  ));
  try {
    $field = new FileFormField($node);
    $this
      ->fail('->initialize() throws a \\LogicException if the node is not a file input field');
  } catch (\LogicException $e) {
    $this
      ->assertTrue(true, '->initialize() throws a \\LogicException if the node is not a file input field');
  }
}