Last active
June 16, 2016 13:22
-
-
Save nVitius/8227172 to your computer and use it in GitHub Desktop.
Timestamp method for Behat
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 | |
use Behat\Behat\Context\ClosuredContextInterface, | |
Behat\Behat\Context\TranslatedContextInterface, | |
Behat\Behat\Context\BehatContext, | |
Behat\Behat\Exception\PendingException; | |
use Behat\Gherkin\Node\PyStringNode, | |
Behat\Gherkin\Node\TableNode; | |
/** | |
* Features context. | |
*/ | |
class FeatureContext extends BehatContext | |
{ | |
/** | |
* Initializes context. | |
* Every scenario gets it's own context object. | |
* | |
* @param array $parameters context parameters (set them up through behat.yml) | |
*/ | |
public function __construct(array $parameters) | |
{ | |
// Initialize your context here | |
} | |
/** | |
* @Transform /^(.*\(timestamp\).*)$/ | |
*/ | |
public function timestamp($string) | |
{ | |
$pattern = '/\(timestamp\)/'; | |
$time = date('i.s'); | |
$timestamp = preg_replace($pattern, $time, $string); | |
return $timestamp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If this is tabular data will it change the value that i printed in the log-output ?
Or will the log output still show "timestamp"