AbstractFixerTest.php 2.1 KB

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