1

我在 Drupal 8 中使用drupalLogin()函数的任何功能性 phpunit 测试都失败了。结果消息是:

User tBQjiDPm successfully logged in.   
Failed asserting that false is true.  

/web/core/tests/Drupal/KernelTests/AssertLegacyTrait.php:35  
/web/core/tests/Drupal/Tests/UiHelperTrait.php:254  

我在 UiHelperTrait.php 中跟踪了drupalLogin()函数,它出现在第 253 行:
$account->sessionId = $this->getSession()->getCookie(\Drupal::service('session_configuration')->getOptions(\Drupal::request())['name']);未设置。

我的感觉是在执行功能测试时没有正确设置会话和/或 cookie。

Drupal 8 已更新到最新版本 (8.7.3),我正在运行 PHPUnit 6.5.14。此外,这在 Lando 中运行 PHP 7.2 和 nginx。

任何帮助表示赞赏。

4

1 回答 1

3

这失败了,因为在 phpunit.xml 中,我已将SIMPLETEST_BASE_URL设置为https。当我将其更改为http时,功能测试正在运行!我不确定这是否是 Lando 中的错误,或者 SimpleTest 是否与 https 不兼容。

于 2019-08-02T04:29:45.810 回答