WordMatcherTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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;
  13. use PhpCsFixer\WordMatcher;
  14. /**
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\WordMatcher
  20. */
  21. final class WordMatcherTest extends TestCase
  22. {
  23. /**
  24. * @dataProvider provideMatchCases
  25. */
  26. public function testMatch(?string $expected, string $needle, array $candidates): void
  27. {
  28. $matcher = new WordMatcher($candidates);
  29. static::assertSame($expected, $matcher->match($needle));
  30. }
  31. public function provideMatchCases(): array
  32. {
  33. return [
  34. [
  35. null,
  36. 'foo',
  37. [
  38. 'no_blank_lines_after_class_opening',
  39. 'no_blank_lines_after_phpdoc',
  40. ],
  41. ],
  42. [
  43. 'no_blank_lines_after_phpdoc',
  44. 'no_blank_lines_after_phpdocs',
  45. [
  46. 'no_blank_lines_after_class_opening',
  47. 'no_blank_lines_after_phpdoc',
  48. ],
  49. ],
  50. [
  51. 'no_blank_lines_after_foo',
  52. 'no_blank_lines_foo',
  53. [
  54. 'no_blank_lines_after_foo',
  55. 'no_blank_lines_before_foo',
  56. ],
  57. ],
  58. [
  59. null,
  60. 'braces',
  61. [
  62. 'elseif',
  63. ],
  64. ],
  65. ];
  66. }
  67. }