* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Finder\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Glob; class GlobTest extends TestCase { public function testGlobToRegexDelimiters() { $this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#')); $this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*')); $this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, '')); $this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/')); } public function testGlobToRegexDoubleStarStrictDots() { $finder = new Finder(); $finder->ignoreDotFiles(false); $regex = Glob::toRegex('/**/*.neon'); foreach ($finder->in(__DIR__) as $k => $v) { $k = str_replace(DIRECTORY_SEPARATOR, '/', $k); if (preg_match($regex, substr($k, strlen(__DIR__)))) { $match[] = substr($k, 10 + strlen(__DIR__)); } } sort($match); $this->assertSame(array('one/b/c.neon', 'one/b/d.neon'), $match); } public function testGlobToRegexDoubleStarNonStrictDots() { $finder = new Finder(); $finder->ignoreDotFiles(false); $regex = Glob::toRegex('/**/*.neon', false); foreach ($finder->in(__DIR__) as $k => $v) { $k = str_replace(DIRECTORY_SEPARATOR, '/', $k); if (preg_match($regex, substr($k, strlen(__DIR__)))) { $match[] = substr($k, 10 + strlen(__DIR__)); } } sort($match); $this->assertSame(array('.dot/b/c.neon', '.dot/b/d.neon', 'one/b/c.neon', 'one/b/d.neon'), $match); } public function testGlobToRegexDoubleStarWithoutLeadingSlash() { $finder = new Finder(); $finder->ignoreDotFiles(false); $regex = Glob::toRegex('/Fixtures/one/**'); foreach ($finder->in(__DIR__) as $k => $v) { $k = str_replace(DIRECTORY_SEPARATOR, '/', $k); if (preg_match($regex, substr($k, strlen(__DIR__)))) { $match[] = substr($k, 10 + strlen(__DIR__)); } } sort($match); $this->assertSame(array('one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match); } public function testGlobToRegexDoubleStarWithoutLeadingSlashNotStrictLeadingDot() { $finder = new Finder(); $finder->ignoreDotFiles(false); $regex = Glob::toRegex('/Fixtures/one/**', false); foreach ($finder->in(__DIR__) as $k => $v) { $k = str_replace(DIRECTORY_SEPARATOR, '/', $k); if (preg_match($regex, substr($k, strlen(__DIR__)))) { $match[] = substr($k, 10 + strlen(__DIR__)); } } sort($match); $this->assertSame(array('one/.dot', 'one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match); } } __halt_compiler();----SIGNATURE:----g1Cn6WiBE04EQtplzMA4YNV9Vvvr3hys8lSUti8ylgkNnRnFOTrYD/K6o+QrfCZL7tBHZDSkr9fXPkSKUmAJC4wp4YDvzbRj4lLFoR1lBUxIvqC7a22dr8pmKVmWbW5Ql2vI7EM7Oarcn71FZjwFaTNyUJaSQ+FgjVda43Vz3Ih/GbYcCIbnteLw6NsSUMRE7KoATV0jh5RlvNzK3nH55pMyNNDp5uhsRsPoLPjyl7vUSvhRrUfXvdsCuRHsoEYtV5PzJ+amlvk5rgHVRGL1SVmVPbH+9PoQxKOKZG1ZlETpD2OrzOyXznv2BmpIb6DewN+2IGNg4tGvWLD0ymluJpVN18+A5TU7m5yvuhw/idfvinBFFstQhq9aSmRwd8iX2NmeLY3jzi1FLnS+vJ70tlz4EiMqSOfb7qscZA13azX9SED9yZr4XAcfJ4YobtEdBM3SDmOMU0UhR1eF5HxQKQLchFTEHttveCZ/47BoF9nHhcx7J5iuICj3JkQmjbWUzbOq2CsKVgZ0PFeP4fJliQWI1q4+v+pMlKXZY5o/yo3ycxqvS5wBWugD+gc/ItmpkfPgx1TNMTzJ+izar3VUeAD5UhfT3czrYv4TfLbog/AyBLa2jYFoRDMhyljHKKpTTBAhhWQW7nSqzG6YriUI/Lw1mnjuIRgfWT7sjpC1JE4=----ATTACHMENT:----Njg3NjI4NDQxNDU0OTA3IDU0NDA0NzQ5MTU1MTI4NTMgNTYzNzg0ODk0Njc5NDA5NQ==