You are here

public function FormTest::testGet 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::testGet()

File

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

Class

FormTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testGet() {
  $form = $this
    ->createForm('<form method="post"><input type="text" name="bar" value="bar" /><input type="submit" /></form>');
  $this
    ->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $form
    ->get('bar'), '->get() returns the field object associated with the given name');
  try {
    $form
      ->get('foo');
    $this
      ->fail('->get() throws an \\InvalidArgumentException if the field does not exist');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->get() throws an \\InvalidArgumentException if the field does not exist');
  }
}