X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FTestwork%2FTester%2FResult%2FResultInterpreter.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FTestwork%2FTester%2FResult%2FResultInterpreter.php;h=5ea9ad1333c1d5541020e296c37d99b168753758;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/behat/behat/src/Behat/Testwork/Tester/Result/ResultInterpreter.php b/vendor/behat/behat/src/Behat/Testwork/Tester/Result/ResultInterpreter.php new file mode 100644 index 000000000..5ea9ad133 --- /dev/null +++ b/vendor/behat/behat/src/Behat/Testwork/Tester/Result/ResultInterpreter.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Behat\Testwork\Tester\Result; + +use Behat\Testwork\Tester\Result\Interpretation\ResultInterpretation; + +/** + * Interprets provided test result (as 1 or 0) using registered interpretations. + * + * @author Konstantin Kudryashov + */ +final class ResultInterpreter +{ + /** + * @var ResultInterpretation[] + */ + private $interpretations = array(); + + /** + * Registers result interpretation. + * + * @param ResultInterpretation $interpretation + */ + public function registerResultInterpretation(ResultInterpretation $interpretation) + { + $this->interpretations[] = $interpretation; + } + + /** + * Interprets result as a UNIX return code (0 for success, 1 for failure). + * + * @param TestResult $result + * + * @return integer + */ + public function interpretResult(TestResult $result) + { + foreach ($this->interpretations as $interpretation) { + if ($interpretation->isFailure($result)) { + return 1; + } + } + + return 0; + } +}