title: phpunit InvalidArgumentException: The current node list is empty
body: <p>Running a test which has this line:</p>
  
  <pre><code>$authorizeForm = $crawler-&gt;selectButton('Authorize')-&gt;form();
  </code></pre>
  
  <p>outputs this error:</p>
  
  <pre><code>There was 1 error:
  
  1) Citiqa\ApiBundle\Tests\Controller\SecurityControllerTest::testLoginAndAuthorize
  InvalidArgumentException: The current node list is empty.
  
  /home/oris/src/citiqa-api/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:648
  /home/oris/src/citiqa-api/src/Citiqa/ApiBundle/Tests/Controller/SecurityControllerTest.php:28
  </code></pre>
  
  <p>I've taken a look at <code>Crawler.php</code> and saw the problematic function:</p>
  
  <pre><code>  public function form(array $values = null, $method = null)
  {
      //var_dump($this);
      if (!count($this)) {
          throw new \InvalidArgumentException('The current node list is empty.');
      }
  
      $form = new Form($this-&gt;getNode(0), $this-&gt;uri, $method);
  
      if (null !== $values) {
          $form-&gt;setValues($values);
      }
  
      return $form;
  }
  </code></pre>
  
  <p><code>$this</code> is in this case the crawler object which extends <code>\SplObjectStorage</code> which implements the <code>Countable</code> interface, so we should be fine. I've tried to <code>var_dump($this);</code> on <code>form()</code> and I see this:</p>
  
  <pre><code>object(Symfony\Component\DomCrawler\Crawler)#1354 (2) {
    ["uri":"Symfony\Component\DomCrawler\Crawler":private]=&gt;
    string(37) "https://localhost/oauth/v2/auth_login"
    ["storage":"SplObjectStorage":private]=&gt;
    array(1) {
      ["0000000075b694bd000000002b32afe0"]=&gt;
  array(2) {
    ["obj"]=&gt;
    object(DOMElement)#529 (18) {
      ["tagName"]=&gt;
      string(6) "button"
      ["schemaTypeInfo"]=&gt;
      NULL
      ["nodeName"]=&gt;
      string(6) "button"
      ["nodeValue"]=&gt;
      string(5) "login"
      ["nodeType"]=&gt;
      int(1)
      ["parentNode"]=&gt;
      string(22) "(object value omitted)"
      ["childNodes"]=&gt;
      string(22) "(object value omitted)"
      ["firstChild"]=&gt;
      string(22) "(object value omitted)"
      ["lastChild"]=&gt;
      string(22) "(object value omitted)"
      ["previousSibling"]=&gt;
      string(22) "(object value omitted)"
      ["nextSibling"]=&gt;
      string(22) "(object value omitted)"
      ["attributes"]=&gt;
      string(22) "(object value omitted)"
      ["ownerDocument"]=&gt;
      string(22) "(object value omitted)"
      ["namespaceURI"]=&gt;
      NULL
      ["prefix"]=&gt;
      string(0) ""
      ["localName"]=&gt;
      string(6) "button"
      ["baseURI"]=&gt;
      NULL
      ["textContent"]=&gt;
      string(5) "login"
    }
    ["inf"]=&gt;
    NULL
     }
    }
   }
  object(Symfony\Component\DomCrawler\Crawler)#1852 (2) {
    ["uri":"Symfony\Component\DomCrawler\Crawler":private]=&gt;
    string(155) "https://localhost/oauth/v2/auth?client_id=1_5ndcb2XXXXX&amp;redirect_uri=http%3A%2F%2Fwww.google.com&amp;response_type=token"
    ["storage":"SplObjectStorage":private]=&gt;
    array(0) {
   }
  }
  </code></pre>
  
  <ul>
  <li><p>phpunit version is 3.6.10</p></li>
  <li><p>Funny thing is, this test is completing successfully on another machine, with a different phpunit version (3.7.21). could this be a version / error reporting level issue?</p></li>
  </ul>