CodeSampleTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\Tests\FixerDefinition;
  12. use PhpCsFixer\FixerDefinition\CodeSample;
  13. use PhpCsFixer\Tests\TestCase;
  14. /**
  15. * @author Andreas Möller <am@localheinz.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\FixerDefinition\CodeSample
  20. */
  21. final class CodeSampleTest extends TestCase
  22. {
  23. public function testConstructorSetsValues()
  24. {
  25. $code = '<php echo $foo;';
  26. $configuration = [
  27. 'foo' => 'bar',
  28. ];
  29. $codeSample = new CodeSample(
  30. $code,
  31. $configuration
  32. );
  33. $this->assertSame($code, $codeSample->getCode());
  34. $this->assertSame($configuration, $codeSample->getConfiguration());
  35. }
  36. public function testConfigurationDefaultsToNull()
  37. {
  38. $codeSample = new CodeSample('<php echo $foo;');
  39. $this->assertNull($codeSample->getConfiguration());
  40. }
  41. }