使用 drupalLogin()函数在Drupal 8中的任何功能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。
感谢您的帮助。
答案 0 :(得分:0)
之所以失败,是因为我在phpunit.xml中将 SIMPLETEST_BASE_URL 设置为 https 。当我将其更改为 http 时,功能测试正在起作用!我不确定这是Lando中的错误还是SimpleTest与https不兼容。