FixerNameValidatorTest.php 2.0 KB

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