WordMatcherTest.php 1.8 KB

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