Created
February 6, 2014 10:31
-
-
Save oziks/8841798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FeatureContext\Page; | |
use SensioLabs\Behat\PageObjectExtension\PageObject\Page; | |
class BasePage extends Page | |
{ | |
/** | |
* Try until | |
* | |
* @param callable $lambda lambda method | |
* @param int $timeout Timeout second | |
* | |
* @return mixed | |
*/ | |
public function tryUntil($lambda, $timeout = 30) | |
{ | |
for ($i = 0; $i < $timeout; $i++) { | |
try { | |
return $lambda($this); | |
} catch (\Exception $e) { | |
if ($timeout == $i) { | |
throw $e; | |
} | |
} | |
sleep(1); | |
} | |
} | |
.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment