FileSpecificCodeSampleTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\FixerDefinition;
  13. use PhpCsFixer\FixerDefinition\FileSpecificCodeSample;
  14. use PhpCsFixer\Tests\TestCase;
  15. /**
  16. * @author Andreas Möller <am@localheinz.com>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\FixerDefinition\FileSpecificCodeSample
  21. */
  22. final class FileSpecificCodeSampleTest extends TestCase
  23. {
  24. public function testDefaults(): void
  25. {
  26. $code = file_get_contents(__FILE__);
  27. $splFileInfo = new \SplFileInfo(__FILE__);
  28. $sample = new FileSpecificCodeSample(
  29. $code,
  30. $splFileInfo
  31. );
  32. self::assertSame($code, $sample->getCode());
  33. self::assertSame($splFileInfo, $sample->getSplFileInfo());
  34. self::assertNull($sample->getConfiguration());
  35. }
  36. public function testConstructorSetsValues(): void
  37. {
  38. $code = file_get_contents(__FILE__);
  39. $splFileInfo = new \SplFileInfo(__FILE__);
  40. $configuration = [
  41. 'foo' => 'bar',
  42. 'bar' => 'baz',
  43. ];
  44. $sample = new FileSpecificCodeSample(
  45. $code,
  46. $splFileInfo,
  47. $configuration
  48. );
  49. self::assertSame($code, $sample->getCode());
  50. self::assertSame($splFileInfo, $sample->getSplFileInfo());
  51. self::assertSame($configuration, $sample->getConfiguration());
  52. }
  53. }