You are here

public function FormTest::testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor in Zircon Profile 8

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

File

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

Class

FormTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor() {
  $dom = new \DOMDocument();
  $dom
    ->loadHTML('
            <html>
                <input type="submit" />
                <form>
                    <input type="foo" />
                </form>
                <button />
            </html>
        ');
  $nodes = $dom
    ->getElementsByTagName('input');
  try {
    $form = new Form($nodes
      ->item(0), 'http://example.com');
    $this
      ->fail('__construct() throws a \\LogicException if the node has no form ancestor');
  } catch (\LogicException $e) {
    $this
      ->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
  }
  try {
    $form = new Form($nodes
      ->item(1), 'http://example.com');
    $this
      ->fail('__construct() throws a \\LogicException if the input type is not submit, button, or image');
  } catch (\LogicException $e) {
    $this
      ->assertTrue(true, '__construct() throws a \\LogicException if the input type is not submit, button, or image');
  }
  $nodes = $dom
    ->getElementsByTagName('button');
  try {
    $form = new Form($nodes
      ->item(0), 'http://example.com');
    $this
      ->fail('__construct() throws a \\LogicException if the node has no form ancestor');
  } catch (\LogicException $e) {
    $this
      ->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
  }
}