MbStrFunctionsFixerTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Fixer\Alias;
  12. use PhpCsFixer\Test\AbstractFixerTestCase;
  13. /**
  14. * @author Filippo Tessarotto <zoeslam@gmail.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\AbstractFunctionReferenceFixer
  19. * @covers \PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer
  20. */
  21. final class MbStrFunctionsFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @param string $expected
  25. * @param null|string $input
  26. *
  27. * @dataProvider provideExamples
  28. */
  29. public function testFix($expected, $input = null)
  30. {
  31. $this->doTest($expected, $input);
  32. }
  33. public function provideExamples()
  34. {
  35. return array(
  36. array('<?php $x = "strlen";'),
  37. array('<?php $x = Foo::strlen("bar");'),
  38. array('<?php $x = new strlen("bar");'),
  39. array('<?php $x = new \strlen("bar");'),
  40. array('<?php $x = new Foo\strlen("bar");'),
  41. array('<?php $x = Foo\strlen("bar");'),
  42. array('<?php $x = strlen::call("bar");'),
  43. array('<?php $x = $foo->strlen("bar");'),
  44. array('<?php $x = strlen();'), // number of arguments mismatch
  45. array('<?php $x = strlen($a, $b);'), // number of arguments mismatch
  46. array('<?php $x = mb_strlen("bar");', '<?php $x = strlen("bar");'),
  47. array('<?php $x = \mb_strlen("bar");', '<?php $x = \strlen("bar");'),
  48. array('<?php $x = mb_strtolower(mb_strstr("bar", "a"));', '<?php $x = strtolower(strstr("bar", "a"));'),
  49. array('<?php $x = mb_strtolower( \mb_strstr ("bar", "a"));', '<?php $x = strtolower( \strstr ("bar", "a"));'),
  50. array('<?php $x = mb_substr("bar", 2, 1);', '<?php $x = substr("bar", 2, 1);'),
  51. array(
  52. '<?php
  53. interface Test
  54. {
  55. public function &strlen($a);
  56. public function strtolower($a);
  57. }',
  58. ),
  59. );
  60. }
  61. }