【发布时间】:2018-06-02 03:16:56
【问题描述】:
我是 Behat 的新手,正在尝试让这个测试在 Behat 3.4.3 版中正常工作。
001 Scenario: Staff users can create accounts # features/user.feature:9
And I register "byron@poetsforever.com" for cleanup # features/user.feature:21
16384: Interacting directly with the RawDrupalContext::$users property has been deprecated.
Use RawDrupalContext::getUserManager->getUsers() instead. in /home/vagrant/.composer/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/RawDrupalContext.php line 152
我认为这是我的 FeatureContext.php 中的违规步骤:
/**
* @When I register :email for cleanup
*/
public function registerUserByEmailForCleanup($email) {
// User must exist or this will throw an error.
$user = $this->userLoadByEmail($email);
$this->users[$user->name] = $user;
}
任何有关如何将其转换为更新步骤以修复弃用错误的指针,或有关如何让 Behat 忽略错误并继续运行的想法将不胜感激。到目前为止还没有运气。谢谢!
【问题讨论】:
-
如果您的上下文扩展了
RawDrupalContext,那么该警告是由$this->users[$user->name] = $user;引起的。您的FeatureContext是否扩展了RawDrupalContext?