FixerNameValidatorTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\FixerNameValidator;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\FixerNameValidator
  19. */
  20. final class FixerNameValidatorTest extends TestCase
  21. {
  22. /**
  23. * @param string $name
  24. * @param bool $isCustom
  25. * @param bool $isValid
  26. *
  27. * @dataProvider provideIsValidCases
  28. */
  29. public function testIsValid($name, $isCustom, $isValid)
  30. {
  31. $validator = new FixerNameValidator();
  32. static::assertSame($isValid, $validator->isValid($name, $isCustom));
  33. }
  34. public function provideIsValidCases()
  35. {
  36. return [
  37. ['', true, false],
  38. ['', false, false],
  39. ['foo', true, false],
  40. ['foo', false, true],
  41. ['foo_bar', false, true],
  42. ['foo_bar_4', false, true],
  43. ['Foo', false, false],
  44. ['fooBar', false, false],
  45. ['4foo', false, false],
  46. ['_foo', false, false],
  47. ['4_foo', false, false],
  48. ['vendor/foo', false, false],
  49. ['bendor/foo', true, false],
  50. ['Vendor/foo', true, true],
  51. ['Vendor4/foo', true, true],
  52. ['4vendor/foo', true, false],
  53. ['Vendor/foo', true, true],
  54. ['FooBar/foo', true, true],
  55. ['Foo-Bar/foo', true, false],
  56. ['Foo_Bar/foo', true, false],
  57. ['Foo/foo/bar', true, false],
  58. ['/foo', true, false],
  59. ['/foo', false, false],
  60. ['/foo/bar', true, false],
  61. ];
  62. }
  63. }