PhpFinderTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Finder\Tests;
  11. use Symfony\Component\Finder\Adapter\PhpAdapter;
  12. use Symfony\Component\Finder\Finder;
  13. /**
  14. * @group legacy
  15. */
  16. class PhpFinderTest extends FinderTest
  17. {
  18. public function testImplementationsAreSynchronized()
  19. {
  20. $adapterReflector = new \ReflectionMethod('Symfony\Component\Finder\Adapter\PhpAdapter', 'searchInDirectory');
  21. $finderReflector = new \ReflectionMethod('Symfony\Component\Finder\Finder', 'searchInDirectory');
  22. $adapterSource = \array_slice(file($adapterReflector->getFileName()), $adapterReflector->getStartLine() + 1, $adapterReflector->getEndLine() - $adapterReflector->getStartLine() - 1);
  23. $adapterSource = implode('', $adapterSource);
  24. $adapterSource = str_replace(array('$this->minDepth', '$this->maxDepth'), array('$minDepth', '$maxDepth'), $adapterSource);
  25. $finderSource = \array_slice(file($finderReflector->getFileName()), $finderReflector->getStartLine() + 1, $finderReflector->getEndLine() - $finderReflector->getStartLine() - 1);
  26. $finderSource = implode('', $finderSource);
  27. $this->assertStringEndsWith($adapterSource, $finderSource);
  28. }
  29. protected function buildFinder()
  30. {
  31. $adapter = new PhpAdapter();
  32. return Finder::create()
  33. ->removeAdapters()
  34. ->addAdapter($adapter);
  35. }
  36. }