TextReporterTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Console\Report\FixReport;
  13. use PhpCsFixer\Console\Report\FixReport\ReporterInterface;
  14. use PhpCsFixer\Console\Report\FixReport\TextReporter;
  15. /**
  16. * @author Boris Gorbylev <ekho@ekho.name>
  17. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\Console\Report\FixReport\TextReporter
  22. */
  23. final class TextReporterTest extends AbstractReporterTestCase
  24. {
  25. protected function createNoErrorReport(): string
  26. {
  27. return <<<'TEXT'
  28. TEXT;
  29. }
  30. protected function createSimpleReport(): string
  31. {
  32. return str_replace(
  33. "\n",
  34. PHP_EOL,
  35. <<<'TEXT'
  36. 1) someFile.php
  37. TEXT
  38. );
  39. }
  40. protected function createWithDiffReport(): string
  41. {
  42. return str_replace(
  43. "\n",
  44. PHP_EOL,
  45. <<<'TEXT'
  46. 1) someFile.php
  47. ---------- begin diff ----------
  48. this text is a diff ;)
  49. ----------- end diff -----------
  50. TEXT
  51. );
  52. }
  53. protected function createWithAppliedFixersReport(): string
  54. {
  55. return str_replace(
  56. "\n",
  57. PHP_EOL,
  58. <<<'TEXT'
  59. 1) someFile.php (some_fixer_name_here_1, some_fixer_name_here_2)
  60. TEXT
  61. );
  62. }
  63. protected function createWithTimeAndMemoryReport(): string
  64. {
  65. return str_replace(
  66. "\n",
  67. PHP_EOL,
  68. <<<'TEXT'
  69. 1) someFile.php
  70. Fixed 1 of 10 files in 1.234 seconds, 2.500 MB memory used
  71. TEXT
  72. );
  73. }
  74. protected function createComplexReport(): string
  75. {
  76. return str_replace(
  77. "\n",
  78. PHP_EOL,
  79. <<<'TEXT'
  80. 1) someFile.php (<comment>some_fixer_name_here_1, some_fixer_name_here_2</comment>)
  81. <comment> ---------- begin diff ----------</comment>
  82. this text is a diff ;)
  83. <comment> ----------- end diff -----------</comment>
  84. 2) anotherFile.php (<comment>another_fixer_name_here</comment>)
  85. <comment> ---------- begin diff ----------</comment>
  86. another diff here ;)
  87. <comment> ----------- end diff -----------</comment>
  88. Found 2 of 10 files that can be fixed in 1.234 seconds, 2.500 MB memory used
  89. TEXT
  90. );
  91. }
  92. protected function createReporter(): ReporterInterface
  93. {
  94. return new TextReporter();
  95. }
  96. protected function getFormat(): string
  97. {
  98. return 'txt';
  99. }
  100. protected function assertFormat(string $expected, string $input): void
  101. {
  102. static::assertSame($expected, $input);
  103. }
  104. }