diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index 26e04127..654d297d 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -141,7 +141,7 @@ final class DatasetsRepository $datasets[$index] = self::getScopedDataset($data, $currentTestFile); } - if (is_callable($datasets[$index])) { + if (! is_array($datasets[$index]) && is_callable($datasets[$index])) { $datasets[$index] = call_user_func($datasets[$index]); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index d0798c20..0f872557 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1764,6 +1764,7 @@ ✓ it shows the correct description for long texts with newlines ✓ it shows the correct description for arrays with many elements ✓ it shows the correct description of datasets with html + ✓ it does not treat a two element dataset of class names as a callable PASS Tests\Unit\Expectations\OppositeExpectation ✓ it throw expectation failed exception with string argument @@ -2225,4 +2226,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1572 passed (3413 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1573 passed (3414 assertions) \ No newline at end of file diff --git a/tests/Unit/DatasetsTests.php b/tests/Unit/DatasetsTests.php index a11bb97a..84d66b33 100644 --- a/tests/Unit/DatasetsTests.php +++ b/tests/Unit/DatasetsTests.php @@ -109,3 +109,27 @@ it('shows the correct description of datasets with html', function (): void { expect($descriptions[0])->toBe('(\'
\')'); }); + +it('does not treat a two element dataset of class names as a callable', function (): void { + $datasets = DatasetsRepository::resolve([ + [ + MagicCallDataset::class, + AnotherMagicCallDataset::class, + ], + ], __FILE__); + + expect(array_values($datasets))->toBe([ + [MagicCallDataset::class], + [AnotherMagicCallDataset::class], + ]); +}); + +class MagicCallDataset +{ + public static function __callStatic(string $name, array $arguments): void + { + throw new RuntimeException('This dataset should not be called.'); + } +} + +class AnotherMagicCallDataset {} diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index ad9f0706..94cfffc6 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -26,13 +26,13 @@ test('parallel', function () use ($run): void { $file = file_get_contents(__FILE__); $file = preg_replace( '/\$expected = \'.*?\';/', - "\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1554 passed (3358 assertions)';", + "\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)';", $file, ); file_put_contents(__FILE__, $file); } - $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1554 passed (3358 assertions)'; + $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)'; expect($output) ->toContain("Tests: {$expected}")