Merge pull request #829 from mozex/allow-pattern-in-uses

Update directory targeting logic to support glob patterns
This commit is contained in:
Nuno Maduro
2023-06-17 16:28:39 +01:00
committed by GitHub
4 changed files with 21 additions and 2 deletions

View File

@ -84,8 +84,10 @@ final class UsesCall
}, $targets);
$this->targets = array_reduce($targets, function (array $accumulator, string $target): array {
if (is_dir($target) || file_exists($target)) {
$accumulator[] = (string) realpath($target);
if (($matches = glob($target)) !== false) {
foreach ($matches as $file) {
$accumulator[] = (string) realpath($file);
}
}
return $accumulator;

View File

@ -0,0 +1,5 @@
<?php
test('closure was bound to CustomTestCase', function () {
$this->assertCustomTrue();
});

View File

@ -0,0 +1,5 @@
<?php
test('closure was bound to CustomTestCase', function () {
$this->assertCustomTrue();
});

View File

@ -1,9 +1,16 @@
<?php
use Tests\CustomTestCase\CustomTestCase;
use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFolder;
uses(CustomTestCaseInSubFolder::class)->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder');
// test case for all the directories inside PHPUnit/GlobPatternTests/SubFolder/
uses(CustomTestCase::class)->in('PHPUnit/GlobPatternTests/SubFolder/*/');
// test case for all the files that end with AsPattern.php inside PHPUnit/GlobPatternTests/SubFolder2/
uses(CustomTestCase::class)->in('PHPUnit/GlobPatternTests/SubFolder2/*AsPattern.php');
uses()->group('integration')->in('Visual');
// NOTE: global test value container to be mutated and checked across files, as needed