Last active
January 13, 2016 21:09
-
-
Save jakubzapletal/2b201f14bcc6e4b0483a 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 | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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