34 $this->_testCase = $testCase;
46 public function __invoke(callable $callback, array $dataSource)
49 \PHPUnit\Framework\IncompleteTestError::class => [],
50 \PHPUnit\Framework\SkippedTestError::class => [],
51 \PHPUnit\Framework\AssertionFailedError::class => [],
54 foreach ($dataSource as $dataSetName => $dataSet) {
56 call_user_func_array($callback, $dataSet);
58 }
catch (\PHPUnit\Framework\IncompleteTestError $exception) {
60 }
catch (\PHPUnit\Framework\SkippedTestError $exception) {
62 }
catch (\PHPUnit\Framework\AssertionFailedError $exception) {
79 protected function prepareMessage(\Exception $exception, $dataSetName, $dataSet)
81 if (!is_string($dataSetName)) {
82 $dataSetName = var_export($dataSet,
true);
84 if ($exception instanceof \PHPUnit\Framework\AssertionFailedError
85 && !$exception instanceof \PHPUnit\Framework\IncompleteTestError
86 && !$exception instanceof \PHPUnit\Framework\SkippedTestError
87 || $this->_options[
'verbose']) {
88 $dataSetName =
'Data set: ' . $dataSetName . PHP_EOL;
92 return $dataSetName . $exception->getMessage() . PHP_EOL
93 . \PHPUnit\Util\Filter::getFilteredStacktrace($exception);
105 $totalCountsMessage = sprintf(
106 'Passed: %d, Failed: %d, Incomplete: %d, Skipped: %d.',
108 count(
$results[\PHPUnit\Framework\AssertionFailedError::class]),
109 count(
$results[\PHPUnit\Framework\IncompleteTestError::class]),
110 count(
$results[\PHPUnit\Framework\SkippedTestError::class])
112 if (
$results[\PHPUnit\Framework\AssertionFailedError::class]) {
113 $this->_testCase->fail(
114 $totalCountsMessage . PHP_EOL .
115 implode(PHP_EOL,
$results[\PHPUnit\Framework\AssertionFailedError::class])
118 if (!
$results[\PHPUnit\Framework\IncompleteTestError::class] &&
119 !
$results[\PHPUnit\Framework\SkippedTestError::class]) {
122 $message = $totalCountsMessage . PHP_EOL . implode(
124 $results[\PHPUnit\Framework\IncompleteTestError::class]
125 ) . PHP_EOL . implode(
127 $results[\PHPUnit\Framework\SkippedTestError::class]
129 if (
$results[\PHPUnit\Framework\IncompleteTestError::class]) {
130 $this->_testCase->markTestIncomplete(
$message);
132 $this->_testCase->markTestSkipped(
$message);
__construct($testCase, array $options=[])
elseif(isset( $params[ 'redirect_parent']))
processResults(array $results, $passed)
__invoke(callable $callback, array $dataSource)
prepareMessage(\Exception $exception, $dataSetName, $dataSet)