FunctionCallSpaceFixerTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Fixer\PSR2;
  11. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  12. /**
  13. * @author Varga Bence <vbence@czentral.org>
  14. */
  15. class FunctionCallSpaceFixerTest extends AbstractFixerTestBase
  16. {
  17. /**
  18. * @dataProvider testFixProvider
  19. */
  20. public function testFix($expected, $input = null)
  21. {
  22. $this->makeTest($expected, $input);
  23. }
  24. public function testFixProvider()
  25. {
  26. return array(
  27. // test function call
  28. array(
  29. '<?php abc($a);',
  30. '<?php abc ($a);',
  31. ),
  32. // test method call
  33. array(
  34. '<?php $o->abc($a);',
  35. '<?php $o->abc ($a);',
  36. ),
  37. // test function-like constructs
  38. array(
  39. '<?php
  40. include("something.php");
  41. include_once("something.php");
  42. require("something.php");
  43. require_once("something.php");
  44. print("hello");
  45. unset($hello);
  46. isset($hello);
  47. empty($hello);
  48. die($hello);
  49. echo("hello");
  50. array("hello");
  51. list($a, $b) = $c;
  52. eval("a");
  53. foo();
  54. $foo = &ref();
  55. ',
  56. '<?php
  57. include ("something.php");
  58. include_once ("something.php");
  59. require ("something.php");
  60. require_once ("something.php");
  61. print ("hello");
  62. unset ($hello);
  63. isset ($hello);
  64. empty ($hello);
  65. die ($hello);
  66. echo ("hello");
  67. array ("hello");
  68. list ($a, $b) = $c;
  69. eval ("a");
  70. foo ();
  71. $foo = &ref ();
  72. ',
  73. ),
  74. array(
  75. '<?php echo foo(1) ? "y" : "n";',
  76. '<?php echo foo (1) ? "y" : "n";',
  77. ),
  78. array(
  79. '<?php echo isset($name) ? "y" : "n";',
  80. '<?php echo isset ($name) ? "y" : "n";',
  81. ),
  82. array(
  83. '<?php include (isHtml())? "1.html": "1.php";',
  84. '<?php include (isHtml ())? "1.html": "1.php";',
  85. ),
  86. // skip other language constructs
  87. array(
  88. '<?php $a = 2 * (1 + 1);',
  89. ),
  90. array(
  91. '<?php echo ($a == $b) ? "foo" : "bar";',
  92. ),
  93. array(
  94. '<?php echo ($a == test($b)) ? "foo" : "bar";',
  95. ),
  96. array(
  97. '<?php include ($html)? "custom.html": "custom.php";',
  98. ),
  99. );
  100. }
  101. }