TextReporterTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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\Report;
  12. use PhpCsFixer\Report\TextReporter;
  13. /**
  14. * @author Boris Gorbylev <ekho@ekho.name>
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Report\TextReporter
  20. */
  21. final class TextReporterTest extends AbstractReporterTestCase
  22. {
  23. public function createNoErrorReport()
  24. {
  25. return <<<'TEXT'
  26. TEXT;
  27. }
  28. public function createSimpleReport()
  29. {
  30. return str_replace(
  31. "\n",
  32. PHP_EOL,
  33. <<<'TEXT'
  34. 1) someFile.php
  35. TEXT
  36. );
  37. }
  38. public function createWithDiffReport()
  39. {
  40. return str_replace(
  41. "\n",
  42. PHP_EOL,
  43. <<<'TEXT'
  44. 1) someFile.php
  45. ---------- begin diff ----------
  46. this text is a diff ;)
  47. ----------- end diff -----------
  48. TEXT
  49. );
  50. }
  51. public function createWithAppliedFixersReport()
  52. {
  53. return str_replace(
  54. "\n",
  55. PHP_EOL,
  56. <<<'TEXT'
  57. 1) someFile.php (some_fixer_name_here_1, some_fixer_name_here_2)
  58. TEXT
  59. );
  60. }
  61. public function createWithTimeAndMemoryReport()
  62. {
  63. return str_replace(
  64. "\n",
  65. PHP_EOL,
  66. <<<'TEXT'
  67. 1) someFile.php
  68. Fixed all files in 1.234 seconds, 2.500 MB memory used
  69. TEXT
  70. );
  71. }
  72. public function createComplexReport()
  73. {
  74. return str_replace(
  75. "\n",
  76. PHP_EOL,
  77. <<<'TEXT'
  78. 1) someFile.php (<comment>some_fixer_name_here_1, some_fixer_name_here_2</comment>)
  79. <comment> ---------- begin diff ----------</comment>
  80. this text is a diff ;)
  81. <comment> ----------- end diff -----------</comment>
  82. 2) anotherFile.php (<comment>another_fixer_name_here</comment>)
  83. <comment> ---------- begin diff ----------</comment>
  84. another diff here ;)
  85. <comment> ----------- end diff -----------</comment>
  86. Checked all files in 1.234 seconds, 2.500 MB memory used
  87. TEXT
  88. );
  89. }
  90. protected function createReporter()
  91. {
  92. return new TextReporter();
  93. }
  94. protected function getFormat()
  95. {
  96. return 'txt';
  97. }
  98. protected function assertFormat($expected, $input)
  99. {
  100. $this->assertSame($expected, $input);
  101. }
  102. }