polevaultweb / codeception-wait
Codeception模块的等待库
1.0
2019-03-03 09:22 UTC
Requires
- php: >=5.4.0
- codeception/codeception: *
This package is auto-updated.
Last update: 2024-08-29 04:37:25 UTC
README
这是一个实用库,旨在帮助用户等待某个条件变为真。
安装
您需要将存储库添加到您的composer.json文件中
composer require --dev polevaultweb/codeception-wait
使用方法
在您的自定义模块中添加一个方法
/** * @param int $timeout_in_second * @param int $interval_in_millisecond * * @return ModuleWait */ protected function wait( $timeout_in_second = 30, $interval_in_millisecond = 250 ) { return new ModuleWait( $this, $timeout_in_second, $interval_in_millisecond ); }
然后您可以创建一个条件并等待它发生,例如。
/** * Wait until an email to be received. * * @param int $timeout * * @throws \Exception */ public function waitForEmail($timeout = 5) { $condition = function () { $message = $this->fetchLastMessage(); return ! empty( $message ); }; $message = sprintf('Waited for %d secs but no email has arrived', $timeout); $this->wait($timeout)->until($condition, $message); }