Skip to content

Commit c620c74

Browse files
committed
Adjust tests to make them run
1 parent 9be6d3a commit c620c74

17 files changed

+68
-48
lines changed

src/ErrorFormatter/CheckstyleErrorFormatter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929

3030
use CodeLts\CliTools\AnalysisResult;
3131
use CodeLts\CliTools\Output;
32-
use CodeLts\CliTools\RelativePathHelper;
32+
use CodeLts\CliTools\File\RelativePathHelper;
3333

3434
class CheckstyleErrorFormatter implements ErrorFormatter
3535
{
3636

37-
private RelativePathHelper $relativePathHelper;
37+
/**
38+
* @var RelativePathHelper
39+
*/
40+
private $relativePathHelper;
3841

3942
public function __construct(RelativePathHelper $relativePathHelper)
4043
{
@@ -126,12 +129,9 @@ private function groupByFile(AnalysisResult $analysisResult): array
126129
{
127130
$files = [];
128131

129-
/** @var \PHPStan\Analyser\Error $fileSpecificError */
132+
/** @var \CodeLts\CliTools\Error $fileSpecificError */
130133
foreach ($analysisResult->getFileSpecificErrors() as $fileSpecificError) {
131-
$absolutePath = $fileSpecificError->getFilePath();
132-
if ($fileSpecificError->getTraitFilePath() !== null) {
133-
$absolutePath = $fileSpecificError->getTraitFilePath();
134-
}
134+
$absolutePath = $fileSpecificError->getFile();
135135
$relativeFilePath = $this->relativePathHelper->getRelativePath(
136136
$absolutePath
137137
);

src/ErrorFormatter/GithubErrorFormatter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
use CodeLts\CliTools\AnalysisResult;
3131
use CodeLts\CliTools\Output;
32-
use CodeLts\CliTools\RelativePathHelper;
32+
use CodeLts\CliTools\File\RelativePathHelper;
3333

3434
/**
3535
* Allow errors to be reported in pull-requests diff when run in a GitHub Action
@@ -38,7 +38,10 @@
3838
class GithubErrorFormatter implements ErrorFormatter
3939
{
4040

41-
private RelativePathHelper $relativePathHelper;
41+
/**
42+
* @var RelativePathHelper
43+
*/
44+
private $relativePathHelper;
4245

4346
private TableErrorFormatter $tableErrorformatter;
4447

src/ErrorFormatter/GitlabErrorFormatter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
use Nette\Utils\Json;
3131
use CodeLts\CliTools\AnalysisResult;
3232
use CodeLts\CliTools\Output;
33-
use CodeLts\CliTools\RelativePathHelper;
33+
use CodeLts\CliTools\File\RelativePathHelper;
3434

3535
/**
3636
* @see https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool
3737
*/
3838
class GitlabErrorFormatter implements ErrorFormatter
3939
{
4040

41-
private RelativePathHelper $relativePathHelper;
41+
/**
42+
* @var RelativePathHelper
43+
*/
44+
private $relativePathHelper;
4245

4346
public function __construct(RelativePathHelper $relativePathHelper)
4447
{

src/ErrorFormatter/JsonErrorFormatter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
class JsonErrorFormatter implements ErrorFormatter
3535
{
3636

37-
private bool $pretty;
37+
/**
38+
* @var bool
39+
*/
40+
private $pretty;
3841

3942
public function __construct(bool $pretty)
4043
{

src/ErrorFormatter/JunitErrorFormatter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929

3030
use CodeLts\CliTools\AnalysisResult;
3131
use CodeLts\CliTools\Output;
32-
use CodeLts\CliTools\RelativePathHelper;
32+
use CodeLts\CliTools\File\RelativePathHelper;
3333
use function sprintf;
3434

3535
class JunitErrorFormatter implements ErrorFormatter
3636
{
3737

38-
private \CodeLts\CliTools\RelativePathHelper $relativePathHelper;
38+
/**
39+
* @var RelativePathHelper
40+
*/
41+
private $relativePathHelper;
3942

4043
public function __construct(RelativePathHelper $relativePathHelper)
4144
{

src/ErrorFormatter/TableErrorFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use CodeLts\CliTools\AnalyseCommand;
3131
use CodeLts\CliTools\AnalysisResult;
3232
use CodeLts\CliTools\Output;
33-
use CodeLts\CliTools\RelativePathHelper;
33+
use CodeLts\CliTools\File\RelativePathHelper;
3434

3535
class TableErrorFormatter implements ErrorFormatter
3636
{

src/ErrorFormatter/TeamcityErrorFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
use CodeLts\CliTools\AnalysisResult;
3131
use CodeLts\CliTools\Output;
32-
use CodeLts\CliTools\RelativePathHelper;
32+
use CodeLts\CliTools\File\RelativePathHelper;
3333

3434
/**
3535
* @see https://www.jetbrains.com/help/teamcity/build-script-interaction-with-teamcity.html#Reporting+Inspections

tests/AbstractTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
use PHPUnit\Framework\TestCase;
88

9-
class AbstractTestCase extends TestCase {
9+
abstract class AbstractTestCase extends TestCase {
1010

1111
}

tests/ErrorFormatter/CheckstyleErrorFormatterTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
*/
2626
declare(strict_types = 1);
2727

28-
namespace CodeLts\CliTools\ErrorFormatter\ErrorFormatter;
28+
namespace CodeLts\CliTools\Tests\ErrorFormatter;
2929

30-
use PHPStan\Analyser\Error;
30+
use CodeLts\CliTools\Error;
3131
use CodeLts\CliTools\AnalysisResult;
32-
use CodeLts\CliTools\SimpleRelativePathHelper;
32+
use CodeLts\CliTools\ErrorFormatter\CheckstyleErrorFormatter;
33+
use CodeLts\CliTools\File\SimpleRelativePathHelper;
3334
use CodeLts\CliTools\Tests\ErrorFormatterTestCase;
3435

3536
class CheckstyleErrorFormatterTest extends ErrorFormatterTestCase
@@ -168,11 +169,8 @@ public function testTraitPath(): void
168169
$formatter = new CheckstyleErrorFormatter(new SimpleRelativePathHelper(__DIR__));
169170
$error = new Error(
170171
'Foo',
171-
__DIR__ . '/FooTrait.php (in context of class Foo)',
172-
5,
173-
true,
174-
__DIR__ . '/Foo.php',
175-
__DIR__ . '/FooTrait.php'
172+
__DIR__ . '/FooTrait.php',
173+
5
176174
);
177175
$formatter->formatErrors(new AnalysisResult(
178176
[$error],

tests/ErrorFormatter/GithubErrorFormatterTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
*/
2626
declare(strict_types = 1);
2727

28-
namespace CodeLts\CliTools\ErrorFormatter\ErrorFormatter;
28+
namespace CodeLts\CliTools\Tests\ErrorFormatter;
2929

30-
use CodeLts\CliTools\FuzzyRelativePathHelper;
31-
use CodeLts\CliTools\NullRelativePathHelper;
30+
use CodeLts\CliTools\File\FuzzyRelativePathHelper;
31+
use CodeLts\CliTools\File\NullRelativePathHelper;
3232
use CodeLts\CliTools\Tests\ErrorFormatterTestCase;
33+
use CodeLts\CliTools\ErrorFormatter\GithubErrorFormatter;
34+
use CodeLts\CliTools\ErrorFormatter\TableErrorFormatter;
3335

3436
class GithubErrorFormatterTest extends ErrorFormatterTestCase
3537
{

0 commit comments

Comments
 (0)