Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e81086

Browse files
committed
[Finder] Test searching in locations with regex special chars in name
If the location to start searching in contains a regex special char like + or ? and the path restriction is a regular expression with a start limitation. No results will be found with at least GnuFindAdapter - e.g.: ``` use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Adapter; mkdir('/tmp/reg+ex/dir/subdir', 0777, true); $finder = Finder::create() ->removeAdapters() ->addAdapter(new Adapter\GnuFindAdapter()); $finder->in('/tmp/reg+ex')->path('/^dir/'); print count($finder)."\n"; ``` Expected result: 2 Actual result is: 0
1 parent 3da421f commit 0e81086

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,20 @@ public function testIteratorKeys(Adapter\AdapterInterface $adapter)
569569
}
570570
}
571571

572+
/**
573+
* @dataProvider getAdaptersTestData
574+
*/
575+
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter)
576+
{
577+
$finder = $this->buildFinder($adapter);
578+
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s')
579+
->path('/^dir/');
580+
581+
$expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir',
582+
'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',);
583+
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
584+
}
585+
572586
public function testAdaptersOrdering()
573587
{
574588
$finder = Finder::create()

src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat

Whitespace-only changes.

0 commit comments

Comments
 (0)