Skip to content

Commit 23c4f3b

Browse files
committed
Add stub validation test
1 parent 55c3f43 commit 23c4f3b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/src/StubTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace mglaman\PHPStanDrupal\Tests;
6+
7+
use PHPStan\Analyser\Error;
8+
use PHPStan\PhpDoc\StubFilesProvider;
9+
use PHPStan\PhpDoc\StubValidator;
10+
use PHPStan\Testing\PHPStanTestCase;
11+
12+
final class StubTest extends PHPStanTestCase
13+
{
14+
use AdditionalConfigFilesTrait;
15+
16+
public function testValid(): void {
17+
$projectStubFiles = self::getContainer()
18+
->getByType(StubFilesProvider::class)
19+
->getProjectStubFiles();
20+
$stubErrors = self::getContainer()
21+
->getByType(StubValidator::class)
22+
->validate($projectStubFiles, true);
23+
$errorsAsArrays = array_map(
24+
static fn (Error $error) => $error->jsonSerialize(),
25+
$stubErrors
26+
);
27+
self::assertEquals(
28+
[],
29+
$errorsAsArrays,
30+
var_export($errorsAsArrays, true)
31+
);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)