Skip to content

Commit faa7e1a

Browse files
committed
Tests: update PHPStanTypeNodeResolverTest - save original PHPStan source to simplify diff with changes, rename to PHPStanTypeNodeResolverSourceCodeChangesTest
1 parent 95a6010 commit faa7e1a

4 files changed

Lines changed: 1045 additions & 38 deletions

File tree

phpcs-ignores.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ignoreErrors:
9393
sniff: PSR1.Files.SideEffects.FoundWithSymbols
9494
message: 'A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 10 and the first side effect is on line 8.'
9595
count: 1
96-
path: tests/PHPStanTypeNodeResolverTest.php
96+
path: tests/PHPStanTypeNodeResolverSourceCodeChangesTest.php
9797

9898
-
9999
sniff: PSR1.Files.SideEffects.FoundWithSymbols
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Forrest79\TypeValidator\Tests;
4+
5+
use PHPStan\PhpDoc\TypeNodeResolver;
6+
use Tester\Assert;
7+
8+
require __DIR__ . '/bootstrap.php';
9+
10+
class PHPStanTypeNodeResolverSourceCodeChangesTest
11+
{
12+
private const string EXPECTED_HASH_MD5 = '3a0d249ba1910a13f10eb5f66acb9ab6';
13+
14+
private const string PHP_SOURCE_FOR_DIFF = __DIR__ . '/assets/phpstan-src/PHPStan_PhpDoc_TypeNodeResolver.phps';
15+
16+
17+
public static function test(): void
18+
{
19+
$rc = new \ReflectionClass(TypeNodeResolver::class);
20+
21+
$filename = $rc->getFileName();
22+
assert(is_string($filename) && file_exists($filename));
23+
24+
$source = file_get_contents($filename);
25+
assert(is_string($source));
26+
27+
$actualHash = md5($source);
28+
29+
file_put_contents(__DIR__ . '/assets/phpstan-src/PHPStan_PhpDoc_TypeNodeResolver.phps', $source);
30+
31+
assert(
32+
$actualHash === self::EXPECTED_HASH_MD5,
33+
sprintf(
34+
'Class %s was changed, expected hash is \'%s\' != actual hash \'%s\' check differences in \'%s\' and update hash.',
35+
TypeNodeResolver::class,
36+
self::EXPECTED_HASH_MD5,
37+
$actualHash,
38+
self::PHP_SOURCE_FOR_DIFF,
39+
),
40+
);
41+
}
42+
43+
}
44+
45+
Assert::noError(static function (): void {
46+
PHPStanTypeNodeResolverSourceCodeChangesTest::test();
47+
});

tests/PHPStanTypeNodeResolverTest.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)