Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
phpunit/Symfony:BadMethodCallException_Php_Symfony_Phpunit - Fatal编程技术网

phpunit/Symfony:BadMethodCallException

phpunit/Symfony:BadMethodCallException,php,symfony,phpunit,Php,Symfony,Phpunit,我想测试我的项目中URL的http状态代码 通过一些测试,我从phpunit获得了以下错误消息: 1) pp\TheBundle\Tests\UrlTests\UrlTests::test18Url PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'BadMethodCallException' with message 'A Crawler cannot be serialized.' in /var/www/

我想测试我的项目中URL的http状态代码

通过一些测试,我从phpunit获得了以下错误消息:

1) pp\TheBundle\Tests\UrlTests\UrlTests::test18Url
PHPUnit_Framework_Exception: PHP Fatal error:  Uncaught exception 'BadMethodCallException' with message 'A Crawler cannot be serialized.' in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:315
Stack trace:
#0 [internal function]: Symfony\Component\DomCrawler\Crawler->serialize()
#1 -(364): serialize(Array)
#2 -(513): __phpunit_run_isolated_test()
#3 {main}
  thrown in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315

Fatal error: Uncaught exception 'BadMethodCallException' with message 'A Crawler cannot be serialized.' in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315

BadMethodCallException: A Crawler cannot be serialized. in /var/www/viasenso/muttersystem/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php on line 315

Call Stack:
    0.0022     441400   1. {main}() -:0
    0.0400    4434840   2. __phpunit_run_isolated_test() -:513
    0.6232   30949432   3. serialize() -:364
    0.6235   31024280   4. Symfony\Component\DomCrawler\Crawler->serialize() -:364
这是测试功能的内容:

$crawler = $this->helper->getCrawler('/de/profil/the-profile/123/veroeffentlichen', [
    'user' => $this->helper->getParameter('testing')['user']['admin']['username'],
    'pwd' => $this->helper->getParameter('testing')['user']['admin']['password'],
]);


$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode(),
    'Status-Code ' . $this->client->getResponse()->getStatusCode() . ' on URL ' . $this->client->getRequest()->getUri() . '');

任何想法,为什么会发生这种错误?来自phpunit的调试信息并没有真正的帮助…

这是一个奇怪的解决方案,但它解决了我的问题。请将assertEquals更改为assertContains。

这是一个奇怪的解决方案,但它解决了我的问题。请将assertEquals更改为assertContains。

将配置进程隔离更改为false,您应获得更清晰的测试失败消息

将配置进程隔离更改为false,您应获得更清晰的测试失败消息

这更适合作为注释。这更适合作为注释。