Skip to content

Instantly share code, notes, and snippets.

@jakubzapletal
Last active January 13, 2016 21:09
Show Gist options
  • Save jakubzapletal/2b201f14bcc6e4b0483a to your computer and use it in GitHub Desktop.
Save jakubzapletal/2b201f14bcc6e4b0483a to your computer and use it in GitHub Desktop.
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
/**
* Defines application features from the specific context.
*/
class FeatureContext implements Context, SnippetAcceptingContext
{
/**
* @When Log exception
*/
public function logException()
{
$logger = new \Monolog\Logger('default');
$path = tmpfile();
$defaultLog = new \Monolog\Handler\StreamHandler($path, \Monolog\Logger::DEBUG);
$logger->pushHandler($defaultLog);
$exception = new \Exception();
$message = "exception: " . $exception->getMessage();
$context = [
'exception' => $exception,
'trace' => $exception->getTrace()
];
$logger->addInfo($message, $context);
}
}
@jakubzapletal
Copy link
Author

I got notice: Notice: Undefined offset: 2 in /var/www/test/vendor/behat/behat/src/Behat/Testwork/Specification/GroupedSpecificationIterator.php on line 98

and fatal error: Fatal error: Call to a member function next() on a non-object in /var/www/test/vendor/behat/behat/src/Behat/Testwork/Specification/GroupedSpecificationIterator.php on line 98

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