Skip to content

Instantly share code, notes, and snippets.

@nVitius
Last active June 16, 2016 13:22
Show Gist options
  • Save nVitius/8227172 to your computer and use it in GitHub Desktop.
Save nVitius/8227172 to your computer and use it in GitHub Desktop.
Timestamp method for Behat
<?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;
}
}
@ijerry
Copy link

ijerry commented Jun 16, 2016

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment