ConfigTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Config;
  11. use Symfony\Component\Finder\Finder;
  12. use Symfony\CS\Config\Config;
  13. use Symfony\CS\Finder\DefaultFinder;
  14. class ConfigTest extends \PHPUnit_Framework_TestCase
  15. {
  16. public function testThatDefaultFinderWorksWithDirSetOnConfig()
  17. {
  18. $config = Config::create();
  19. $config->setDir(__DIR__.'/../Fixtures/FinderDirectory');
  20. $iterator = $config->getFinder()->getIterator();
  21. $this->assertSame(1, count($iterator));
  22. $iterator->rewind();
  23. $this->assertSame('somefile.php', $iterator->current()->getFilename());
  24. }
  25. public function testThatCustomDefaultFinderWorks()
  26. {
  27. $finder = DefaultFinder::create();
  28. $finder->in(__DIR__.'/../Fixtures/FinderDirectory');
  29. $config = Config::create();
  30. $config->finder($finder);
  31. $iterator = $config->getFinder()->getIterator();
  32. $this->assertSame(1, count($iterator));
  33. $iterator->rewind();
  34. $this->assertSame('somefile.php', $iterator->current()->getFilename());
  35. }
  36. public function testThatCustomFinderWorks()
  37. {
  38. $finder = Finder::create();
  39. $finder->in(__DIR__.'/../Fixtures/FinderDirectory');
  40. $config = Config::create();
  41. $config->finder($finder);
  42. $iterator = $config->getFinder()->getIterator();
  43. $this->assertSame(1, count($iterator));
  44. $iterator->rewind();
  45. $this->assertSame('somefile.php', $iterator->current()->getFilename());
  46. }
  47. }