我在 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。
任何帮助表示赞赏。