WordMatcherTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. * @param string[] $candidates
  25. *
  26. * @dataProvider provideMatchCases
  27. */
  28. public function testMatch(?string $expected, string $needle, array $candidates): void
  29. {
  30. $matcher = new WordMatcher($candidates);
  31. static::assertSame($expected, $matcher->match($needle));
  32. }
  33. public static function provideMatchCases(): array
  34. {
  35. return [
  36. [
  37. null,
  38. 'foo',
  39. [
  40. 'no_blank_lines_after_class_opening',
  41. 'no_blank_lines_after_phpdoc',
  42. ],
  43. ],
  44. [
  45. 'no_blank_lines_after_phpdoc',
  46. 'no_blank_lines_after_phpdocs',
  47. [
  48. 'no_blank_lines_after_class_opening',
  49. 'no_blank_lines_after_phpdoc',
  50. ],
  51. ],
  52. [
  53. 'no_blank_lines_after_foo',
  54. 'no_blank_lines_foo',
  55. [
  56. 'no_blank_lines_after_foo',
  57. 'no_blank_lines_before_foo',
  58. ],
  59. ],
  60. [
  61. null,
  62. 'braces',
  63. [
  64. 'elseif',
  65. ],
  66. ],
  67. ];
  68. }
  69. }