Convert stub map check into a phpunit test and add it to tests runner
This commit is contained in:
parent
928cd0645b
commit
74630bcacf
|
@ -44,7 +44,7 @@ jobs:
|
|||
run: docker-compose -f docker-compose.yml run test_runner composer install
|
||||
|
||||
- name: Test Stubs Map
|
||||
run: ./tests/Tools/check-stub-map
|
||||
run: docker-compose -f docker-compose.yml run test_runner vendor/bin/phpunit --testsuite Check_Stub_Map
|
||||
|
||||
- name: run cs fixer
|
||||
run: docker-compose -f docker-compose.yml run test_runner composer cs
|
||||
|
|
|
@ -73,5 +73,8 @@
|
|||
<testsuite name="PhpDoc">
|
||||
<file>tests/StubsPhpDocTest.php</file>
|
||||
</testsuite>
|
||||
<testsuite name="Check_Stub_Map">
|
||||
<file>tests/CheckStubMapTest.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
echo "Installing composer packages..."
|
||||
docker-compose -f docker-compose.yml run test_runner composer install --ignore-platform-reqs
|
||||
echo "Checking stub map..."
|
||||
docker-compose -f docker-compose.yml run test_runner vendor/bin/phpunit --testsuite Check_Stub_Map
|
||||
phpVersions=("7.1" "7.2" "7.3" "7.4" "8.0" "8.1")
|
||||
for i in "${phpVersions[@]}"
|
||||
do
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace StubTests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CheckStubMapTest extends TestCase
|
||||
{
|
||||
private $oldMapFile = __DIR__ . '/../PhpStormStubsMap.php';
|
||||
private $newMapFile;
|
||||
|
||||
public function testStubMapIsUpToDate(): void
|
||||
{
|
||||
$this->assertFileEquals(
|
||||
$this->newMapFile,
|
||||
$this->oldMapFile,
|
||||
'The commited stub map is not up to date. Please regenerate it using ./generate-stub-map'
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->newMapFile = tempnam(__DIR__ . '/../', 'stub');
|
||||
$generator = escapeshellarg(__DIR__ . '/Tools/generate-stub-map');
|
||||
$newStubMap = escapeshellarg($this->newMapFile);
|
||||
exec("php $generator $newStubMap", $output, $exitCode);
|
||||
if ($exitCode) {
|
||||
$this->fail("PHP script $generator exited with code $exitCode: " . implode("\n", $output));
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
unlink($this->newMapFile);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuox pipefail
|
||||
|
||||
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
readonly CURRENT_FILE_HASH=$(md5sum "$scriptPath/../../PhpStormStubsMap.php" | awk '{ print $1 }')
|
||||
|
||||
# Generate the stub map again
|
||||
php "$scriptPath/generate-stub-map"
|
||||
|
||||
readonly NEW_FILE_HASH=$(md5sum "$scriptPath/../../PhpStormStubsMap.php" | awk '{ print $1 }')
|
||||
|
||||
if [[ "${CURRENT_FILE_HASH}" != "${NEW_FILE_HASH}" ]]; then
|
||||
echo "The commited stub map is not up to date. Please regenerate it using ./generate-stub-map";
|
||||
cat "$scriptPath/../../PhpStormStubsMap.php"
|
||||
exit 1;
|
||||
fi
|
|
@ -36,7 +36,7 @@ use const PHP_EOL;
|
|||
(function (): void {
|
||||
require __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$mapFile = __DIR__ . '/../../PhpStormStubsMap.php';
|
||||
$mapFile = $GLOBALS['argv'][1] ?? __DIR__ . '/../../PhpStormStubsMap.php';
|
||||
|
||||
class InvalidConstantNode extends RuntimeException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue