AbstractFixerTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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;
  12. use PhpCsFixer\Tests\Fixtures\Test\AbstractFixerTest\UnconfigurableFixer;
  13. use PhpCsFixer\WhitespacesFixerConfig;
  14. /**
  15. * @internal
  16. *
  17. * @covers \PhpCsFixer\AbstractFixer
  18. */
  19. final class AbstractFixerTest extends TestCase
  20. {
  21. public function testConfigureUnconfigurable()
  22. {
  23. $fixer = new UnconfigurableFixer();
  24. static::assertSame(0, $fixer->getPriority());
  25. static::assertSame('unconfigurable', $fixer->getName());
  26. $this->expectException(\LogicException::class);
  27. $this->expectExceptionMessage('Cannot configure using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  28. $fixer->configure(['foo' => 'bar']);
  29. }
  30. public function testGetConfigurationDefinitionUnconfigurable()
  31. {
  32. $fixer = new UnconfigurableFixer();
  33. $this->expectException(\LogicException::class);
  34. $this->expectExceptionMessage('Cannot get configuration definition using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  35. $fixer->getConfigurationDefinition();
  36. }
  37. public function testCreateConfigurationDefinitionUnconfigurable()
  38. {
  39. $fixer = new UnconfigurableFixer();
  40. $this->expectException(\LogicException::class);
  41. $this->expectExceptionMessage('Cannot create configuration definition using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  42. $fixer->doSomethingWithCreateConfigDefinition();
  43. }
  44. public function testSetWhitespacesConfigUnconfigurable()
  45. {
  46. $fixer = new UnconfigurableFixer();
  47. $this->expectException(\LogicException::class);
  48. $this->expectExceptionMessage('Cannot run method for class not implementing "PhpCsFixer\Fixer\WhitespacesAwareFixerInterface".');
  49. $fixer->setWhitespacesConfig(new WhitespacesFixerConfig());
  50. }
  51. }