ObjectOperatorWithoutWhitespaceFixerTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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\Operator;
  12. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  13. /**
  14. * @author Farhad Safarov <farhad.safarov@gmail.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer
  19. */
  20. final class ObjectOperatorWithoutWhitespaceFixerTest extends AbstractFixerTestCase
  21. {
  22. /**
  23. * @param string $expected
  24. * @param null|string $input
  25. *
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix($expected, $input = null)
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. public function provideFixCases()
  33. {
  34. return [
  35. [
  36. '<?php $object->method();',
  37. '<?php $object ->method();',
  38. ],
  39. [
  40. '<?php $object->method();',
  41. '<?php $object -> method();',
  42. ],
  43. [
  44. '<?php $object->method();',
  45. '<?php $object-> method();',
  46. ],
  47. [
  48. '<?php $object->method();',
  49. '<?php $object ->method();',
  50. ],
  51. [
  52. '<?php $object->method();',
  53. '<?php $object-> method();',
  54. ],
  55. [
  56. '<?php $object->method();',
  57. '<?php $object -> method();',
  58. ],
  59. [
  60. '<?php echo "use it as -> you want";',
  61. ],
  62. // Ensure that doesn't break chained multi-line statements
  63. [
  64. '<?php $object->method()
  65. ->method2()
  66. ->method3();',
  67. ],
  68. [
  69. '<?php $this
  70. ->add()
  71. // Some comment
  72. ->delete();',
  73. ],
  74. ];
  75. }
  76. }