Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Exception / Stringer / PHPUnitExceptionStringer.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Exception\Stringer;
12
13 use Exception;
14
15 /**
16  * Strings PHPUnit assertion exceptions.
17  *
18  * @see ExceptionPresenter
19  *
20  * @author Konstantin Kudryashov <ever.zet@gmail.com>
21  */
22 final class PHPUnitExceptionStringer implements ExceptionStringer
23 {
24     /**
25      * {@inheritdoc}
26      */
27     public function supportsException(Exception $exception)
28     {
29         return $exception instanceof \PHPUnit_Framework_Exception
30             || $exception instanceof \PHPUnit\Framework\Exception;
31     }
32
33     /**
34      * {@inheritdoc}
35      */
36     public function stringException(Exception $exception, $verbosity)
37     {
38         if (!class_exists('PHPUnit\\Framework\\TestFailure')) {
39             return trim(\PHPUnit_Framework_TestFailure::exceptionToString($exception));
40         }
41
42         // PHPUnit assertion exceptions do not include expected / observed info in their
43         // messages, but expect the test listeners to format that info like the following
44         // (see e.g. PHPUnit_TextUI_ResultPrinter::printDefectTrace)
45         return trim(\PHPUnit\Framework\TestFailure::exceptionToString($exception));
46     }
47 }