WordMatcherTest.php 1.8 KB

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