-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for ClassConstantResultAnalyser, fix regex message
- Loading branch information
1 parent
8e0a573
commit cd2fea5
Showing
5 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\SwissKnife\Tests\PHPStan; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Rector\SwissKnife\PHPStan\ClassConstantResultAnalyser; | ||
use Rector\SwissKnife\ValueObject\ClassConstMatch; | ||
|
||
final class ClassConstantResultAnalyserTest extends TestCase | ||
{ | ||
private ClassConstantResultAnalyser $classConstantResultAnalyser; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->classConstantResultAnalyser = new ClassConstantResultAnalyser(); | ||
} | ||
|
||
public function test(): void | ||
{ | ||
$phpstanResult = [ | ||
'files' => [ | ||
'some_file_path.php' => [ | ||
'messages' => [ | ||
[ | ||
'line' => 10, | ||
'message' => 'Access to undefined constant App\\SomeClass::SOME_CONSTANT', | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$publicAndProtectedClassConstants = $this->classConstantResultAnalyser->analyseResult($phpstanResult); | ||
|
||
$this->assertFalse($publicAndProtectedClassConstants->isEmpty()); | ||
$this->assertSame(0, $publicAndProtectedClassConstants->getPublicCount()); | ||
$this->assertSame(1, $publicAndProtectedClassConstants->getProtectedCount()); | ||
|
||
$onlyProtectedClassConstMatch = $publicAndProtectedClassConstants->getProtectedClassConstMatches()[0]; | ||
$this->assertInstanceOf(ClassConstMatch::class, $onlyProtectedClassConstMatch); | ||
|
||
// $this->assertSame('SOME_CONST', $onlyProtectedClassConstMatch->getConstantName()); | ||
$this->assertSame('App\SomeClass', $onlyProtectedClassConstMatch->getClassName()); | ||
} | ||
} |