polevaultweb / codeception-wait
Wait library for modules of Codeception
Installs: 3 271
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- codeception/codeception: *
This package is auto-updated.
Last update: 2024-11-29 05:21:20 UTC
README
A utility library, designed to help the user to wait until a condition turns true.
Installation
You need to add the repository into your composer.json file
composer require --dev polevaultweb/codeception-wait
Usage
In your custom module add a method:
/** * @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 ); }
Then you can create a condition and wait for it to happen, e.g.
/** * 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); }