Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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
Php 如果测试的操作重定向,则电子邮件功能测试失败_Php_Symfony_Functional Testing_Swiftmailer - Fatal编程技术网

Php 如果测试的操作重定向,则电子邮件功能测试失败

Php 如果测试的操作重定向,则电子邮件功能测试失败,php,symfony,functional-testing,swiftmailer,Php,Symfony,Functional Testing,Swiftmailer,控制器操作导致发送电子邮件,然后重定向。由于重定向,此操作的功能测试失败。如果重写控制器以呈现模板,则测试通过。[这似乎通常是正确的;可以使用[Symfony的文档][1]中的代码复制这种情况。] 编辑:测试失败 “/usr/bin/php”“/usr/bin/phpunit”“--colors”“--log junit” /tmp/nb phpunit log.xml”“--引导 “/home/george/志愿者/app/bootstrap.php.cache”“--配置” “/home/g

控制器操作导致发送电子邮件,然后重定向。由于重定向,此操作的功能测试失败。如果重写控制器以呈现模板,则测试通过。[这似乎通常是正确的;可以使用[Symfony的文档][1]中的代码复制这种情况。]

编辑:测试失败 “/usr/bin/php”“/usr/bin/phpunit”“--colors”“--log junit” /tmp/nb phpunit log.xml”“--引导 “/home/george/志愿者/app/bootstrap.php.cache”“--配置” “/home/george/志愿者/app/phpunit.xml.dist”“--过滤器” “%\b启动组织\b%” “/home/george/netbeans-8.0.1/php/phpunit/netbeansuite.php” “--run=/home/george/志愿者/src/Truckee/MatchingBundle/Tests/Controller/AdminControllerTest.php” 塞巴斯蒂安·伯格曼著,第3.7.28页

从/home/george/志愿者/app/phpunit.xml.dist读取配置

F

时间:1.36秒,内存:40.75Mb

有1次失败:

(一) Truckee\MatchingBundle\Tests\Controller\AdminControllerTest::testActivateOrganization 断言0与预期1匹配失败

/home/george/志愿者/src/Truckee/MatchingBundle/Tests/Controller/administralertest.php:64

失败!测试:1,断言:1,失败:1

完成了

控制器 编辑3:更完整的测试夹具
将此添加到单元测试:

 $this->client->followRedirects(false);
看。重定向不会自动执行,但您正在设置重定向。如果您想在测试电子邮件后执行下一个重定向,可以调用J

$crawler = $client->followRedirect();
如果要更改回所有重定向,请致电:

$client->followRedirects();

您在问题中写道“由于重定向,此操作的功能测试失败”-您能否详细说明测试的方式以及测试失败时的情况(例如,当您通过命令行testrunner运行测试时,请向stdout显示输出)。@hakre:上面编辑中的测试输出。测试作为重点测试方法在Netbeans IDE中运行。请尝试从历史记录中的上一个请求获取配置文件,因为客户端已经执行了重定向(我假设)。@hakre:assessment是正确的。测试
setup()
包括
$this->client->followRedirects()。创建客户端的代码在哪里?根据Symfony文档,在单元测试中不应自动遵循重定向。请参见上面编辑的测试夹具。我假设执行
$this->client->followRedirects()setup()
中的code>允许我不包括
$this->client->followRedirect()
此装置中的任何地方都可能发生重定向。客户端中的
setUp()
函数会为每个单元测试重新创建,因此,如果您不希望特定测试遵循该函数,则只需添加
$this->client->follow Redirects(false)位于单个测试的顶部!明智地放置
$this->client->followRedirects(false)(即,不一定在顶部!)允许测试通过。非常感谢。
$crawler = $client->followRedirect();
$client->followRedirects();