PHP code example of polevaultweb / codeception-wait

1. Go to this page and download the library: Download polevaultweb/codeception-wait library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

polevaultweb / codeception-wait example snippets


/**
 * @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);
}