Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony phpunit InvalidArgumentException:当前节点列表为空_Symfony_Phpunit - Fatal编程技术网

Symfony phpunit InvalidArgumentException:当前节点列表为空

Symfony phpunit InvalidArgumentException:当前节点列表为空,symfony,phpunit,Symfony,Phpunit,运行具有以下行的测试: $authorizeForm = $crawler->selectButton('Authorize')->form(); 输出此错误: There was 1 error: 1) Citiqa\ApiBundle\Tests\Controller\SecurityControllerTest::testLoginAndAuthorize InvalidArgumentException: The current node list is empty.

运行具有以下行的测试:

$authorizeForm = $crawler->selectButton('Authorize')->form();
输出此错误:

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
我查看了
Crawler.php
,看到了有问题的函数:

  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->getNode(0), $this->uri, $method);

    if (null !== $values) {
        $form->setValues($values);
    }

    return $form;
}
$this
在本例中是一个爬虫对象,它扩展了
\SplObjectStorage
,实现了
可数
接口,所以我们应该可以。我试图
var\u dump($this)
form()
上,我看到:

object(Symfony\Component\DomCrawler\Crawler)#1354 (2) {
  ["uri":"Symfony\Component\DomCrawler\Crawler":private]=>
  string(37) "https://localhost/oauth/v2/auth_login"
  ["storage":"SplObjectStorage":private]=>
  array(1) {
    ["0000000075b694bd000000002b32afe0"]=>
array(2) {
  ["obj"]=>
  object(DOMElement)#529 (18) {
    ["tagName"]=>
    string(6) "button"
    ["schemaTypeInfo"]=>
    NULL
    ["nodeName"]=>
    string(6) "button"
    ["nodeValue"]=>
    string(5) "login"
    ["nodeType"]=>
    int(1)
    ["parentNode"]=>
    string(22) "(object value omitted)"
    ["childNodes"]=>
    string(22) "(object value omitted)"
    ["firstChild"]=>
    string(22) "(object value omitted)"
    ["lastChild"]=>
    string(22) "(object value omitted)"
    ["previousSibling"]=>
    string(22) "(object value omitted)"
    ["nextSibling"]=>
    string(22) "(object value omitted)"
    ["attributes"]=>
    string(22) "(object value omitted)"
    ["ownerDocument"]=>
    string(22) "(object value omitted)"
    ["namespaceURI"]=>
    NULL
    ["prefix"]=>
    string(0) ""
    ["localName"]=>
    string(6) "button"
    ["baseURI"]=>
    NULL
    ["textContent"]=>
    string(5) "login"
  }
  ["inf"]=>
  NULL
   }
  }
 }
object(Symfony\Component\DomCrawler\Crawler)#1852 (2) {
  ["uri":"Symfony\Component\DomCrawler\Crawler":private]=>
  string(155) "https://localhost/oauth/v2/auth?client_id=1_5ndcb2XXXXX&redirect_uri=http%3A%2F%2Fwww.google.com&response_type=token"
  ["storage":"SplObjectStorage":private]=>
  array(0) {
 }
}
  • phpunit版本是3.6.10

  • 有趣的是,这个测试在另一台机器上成功完成,使用的是不同的phpunit版本(3.7.21)。这可能是版本/错误报告级别的问题吗


似乎找不到授权按钮