GitlabReporterTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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\GitlabReporter;
  13. /**
  14. * @author Hans-Christian Otto <c.otto@suora.com>
  15. *
  16. * @internal
  17. * @covers \PhpCsFixer\Report\GitlabReporter
  18. */
  19. final class GitlabReporterTest extends AbstractReporterTestCase
  20. {
  21. protected function createReporter()
  22. {
  23. return new GitlabReporter();
  24. }
  25. protected function getFormat()
  26. {
  27. return 'gitlab';
  28. }
  29. /**
  30. * @return string
  31. */
  32. protected function createNoErrorReport()
  33. {
  34. return '[]';
  35. }
  36. /**
  37. * @return string
  38. */
  39. protected function createSimpleReport()
  40. {
  41. return <<<'JSON'
  42. [{
  43. "description": "some_fixer_name_here",
  44. "location.path": "someFile.php",
  45. "location.lines.begin": 0,
  46. "fingerprint": "ad098ea6ea7a28dd85dfcdfc9e2bded0"
  47. }]
  48. JSON;
  49. }
  50. /**
  51. * @return string
  52. */
  53. protected function createWithDiffReport()
  54. {
  55. return $this->createSimpleReport();
  56. }
  57. /**
  58. * @return string
  59. */
  60. protected function createWithAppliedFixersReport()
  61. {
  62. return <<<'JSON'
  63. [{
  64. "description": "some_fixer_name_here_1",
  65. "location.path": "someFile.php",
  66. "location.lines.begin": 0,
  67. "fingerprint": "b74e9385c8ae5b1f575c9c8226c7deff"
  68. },{
  69. "description": "some_fixer_name_here_2",
  70. "location.path": "someFile.php",
  71. "location.lines.begin": 0,
  72. "fingerprint": "acad4672140c737a83c18d1474d84074"
  73. }]
  74. JSON;
  75. }
  76. /**
  77. * @return string
  78. */
  79. protected function createWithTimeAndMemoryReport()
  80. {
  81. return $this->createSimpleReport();
  82. }
  83. /**
  84. * @return string
  85. */
  86. protected function createComplexReport()
  87. {
  88. return <<<'JSON'
  89. [{
  90. "description": "some_fixer_name_here_1",
  91. "location.path": "someFile.php",
  92. "location.lines.begin": 0,
  93. "fingerprint": "b74e9385c8ae5b1f575c9c8226c7deff"
  94. },{
  95. "description": "some_fixer_name_here_2",
  96. "location.path": "someFile.php",
  97. "location.lines.begin": 0,
  98. "fingerprint": "acad4672140c737a83c18d1474d84074"
  99. },{
  100. "description": "another_fixer_name_here",
  101. "location.path": "anotherFile.php",
  102. "location.lines.begin": 0,
  103. "fingerprint": "30e86e533dac0f1b93bbc3a55c6908f8"
  104. }]
  105. JSON;
  106. }
  107. protected function assertFormat($expected, $input)
  108. {
  109. $this->assertJsonStringEqualsJsonString($expected, $input);
  110. }
  111. }