AbstractFixerTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\WhitespacesFixerConfig;
  14. use PHPUnit\Framework\TestCase;
  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, 'Cannot configure using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  26. $fixer->configure(['foo' => 'bar']);
  27. }
  28. public function testGetConfigurationDefinitionUnconfigurable()
  29. {
  30. $fixer = new UnconfigurableFixer();
  31. $this->expectException(\LogicException::class, 'Cannot get configuration definition using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  32. $fixer->getConfigurationDefinition();
  33. }
  34. public function testCreateConfigurationDefinitionUnconfigurable()
  35. {
  36. $fixer = new UnconfigurableFixer();
  37. $this->expectException(\LogicException::class, 'Cannot create configuration definition using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
  38. $fixer->doSomethingWithCreateConfigDefinition();
  39. }
  40. public function testSetWhitespacesConfigUnconfigurable()
  41. {
  42. $fixer = new UnconfigurableFixer();
  43. $this->expectException('LogicException');
  44. $this->expectExceptionMessage('Cannot run method for class not implementing "PhpCsFixer\Fixer\WhitespacesAwareFixerInterface".');
  45. $fixer->setWhitespacesConfig(new WhitespacesFixerConfig());
  46. }
  47. }