1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 17:12:51 +00:00

PHPStan/tests updates (#11996)

* Remove a bunch of inline ignores and migrate all PHPUnit assertions to static calls

* Update baseline (1573, 93)

* Update commit hash
This commit is contained in:
Jordi Boggiano 2024-05-29 23:12:06 +02:00 committed by GitHub
parent dd8af946fd
commit 37d722e73c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
141 changed files with 1342 additions and 1382 deletions

View file

@ -57,7 +57,7 @@ class FilesystemTest extends TestCase
public function testFindShortestPathCode(string $a, string $b, bool $directory, string $expected, bool $static = false): void
{
$fs = new Filesystem;
$this->assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory, $static));
self::assertEquals($expected, $fs->findShortestPathCode($a, $b, $directory, $static));
}
public static function providePathCouplesAsCode(): array
@ -116,7 +116,7 @@ class FilesystemTest extends TestCase
public function testFindShortestPath(string $a, string $b, string $expected, bool $directory = false): void
{
$fs = new Filesystem;
$this->assertEquals($expected, $fs->findShortestPath($a, $b, $directory));
self::assertEquals($expected, $fs->findShortestPath($a, $b, $directory));
}
public static function providePathCouples(): array
@ -171,8 +171,8 @@ class FilesystemTest extends TestCase
file_put_contents($this->workingDir . "/level1/level2/hello.txt", "hello world");
$fs = new Filesystem;
$this->assertTrue($fs->removeDirectoryPhp($this->workingDir));
$this->assertFileDoesNotExist($this->workingDir . "/level1/level2/hello.txt");
self::assertTrue($fs->removeDirectoryPhp($this->workingDir));
self::assertFileDoesNotExist($this->workingDir . "/level1/level2/hello.txt");
}
public function testFileSize(): void
@ -180,7 +180,7 @@ class FilesystemTest extends TestCase
file_put_contents($this->testFile, 'Hello');
$fs = new Filesystem;
$this->assertGreaterThanOrEqual(5, $fs->size($this->testFile));
self::assertGreaterThanOrEqual(5, $fs->size($this->testFile));
}
public function testDirectorySize(): void
@ -190,7 +190,7 @@ class FilesystemTest extends TestCase
file_put_contents($this->workingDir."/file2.txt", 'World');
$fs = new Filesystem;
$this->assertGreaterThanOrEqual(10, $fs->size($this->workingDir));
self::assertGreaterThanOrEqual(10, $fs->size($this->workingDir));
}
/**
@ -199,7 +199,7 @@ class FilesystemTest extends TestCase
public function testNormalizePath(string $expected, string $actual): void
{
$fs = new Filesystem;
$this->assertEquals($expected, $fs->normalizePath($actual));
self::assertEquals($expected, $fs->normalizePath($actual));
}
public static function provideNormalizedPaths(): array
@ -251,8 +251,8 @@ class FilesystemTest extends TestCase
$fs = new Filesystem();
$result = $fs->unlink($symlinked);
$this->assertTrue($result);
$this->assertFileDoesNotExist($symlinked);
self::assertTrue($result);
self::assertFileDoesNotExist($symlinked);
}
/**
@ -283,9 +283,9 @@ class FilesystemTest extends TestCase
$fs = new Filesystem();
$result = $fs->removeDirectory($symlinkedTrailingSlash);
$this->assertTrue($result);
$this->assertFileDoesNotExist($symlinkedTrailingSlash);
$this->assertFileDoesNotExist($symlinked);
self::assertTrue($result);
self::assertFileDoesNotExist($symlinkedTrailingSlash);
self::assertFileDoesNotExist($symlinked);
}
public function testJunctions(): void
@ -295,8 +295,8 @@ class FilesystemTest extends TestCase
// Non-Windows systems do not support this and will return false on all tests, and an exception on creation
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->assertFalse($fs->isJunction($this->workingDir));
$this->assertFalse($fs->removeJunction($this->workingDir));
self::assertFalse($fs->isJunction($this->workingDir));
self::assertFalse($fs->removeJunction($this->workingDir));
self::expectException('LogicException');
self::expectExceptionMessage('not available on non-Windows platform');
}
@ -306,16 +306,16 @@ class FilesystemTest extends TestCase
// Create and detect junction
$fs->junction($target, $junction);
$this->assertTrue($fs->isJunction($junction), $junction . ': is a junction');
$this->assertFalse($fs->isJunction($target), $target . ': is not a junction');
$this->assertTrue($fs->isJunction($target . '/../../junction'), $target . '/../../junction: is a junction');
$this->assertFalse($fs->isJunction($junction . '/../real'), $junction . '/../real: is not a junction');
$this->assertTrue($fs->isJunction($junction . '/../junction'), $junction . '/../junction: is a junction');
self::assertTrue($fs->isJunction($junction), $junction . ': is a junction');
self::assertFalse($fs->isJunction($target), $target . ': is not a junction');
self::assertTrue($fs->isJunction($target . '/../../junction'), $target . '/../../junction: is a junction');
self::assertFalse($fs->isJunction($junction . '/../real'), $junction . '/../real: is not a junction');
self::assertTrue($fs->isJunction($junction . '/../junction'), $junction . '/../junction: is a junction');
// Remove junction
$this->assertDirectoryExists($junction, $junction . ' is a directory');
$this->assertTrue($fs->removeJunction($junction), $junction . ' has been removed');
$this->assertDirectoryDoesNotExist($junction, $junction . ' is not a directory');
self::assertDirectoryExists($junction, $junction . ' is a directory');
self::assertTrue($fs->removeJunction($junction), $junction . ' has been removed');
self::assertDirectoryDoesNotExist($junction, $junction . ' is not a directory');
}
public function testOverrideJunctions(): void
@ -335,19 +335,19 @@ class FilesystemTest extends TestCase
$fs->junction($old_target, $junction);
$fs->junction($target, $junction);
$this->assertTrue($fs->isJunction($junction), $junction.': is a junction');
$this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
self::assertTrue($fs->isJunction($junction), $junction.': is a junction');
self::assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
//Remove junction
$this->assertTrue($fs->removeJunction($junction), $junction . ' has been removed');
self::assertTrue($fs->removeJunction($junction), $junction . ' has been removed');
// Override broken junction
$fs->junction($old_target, $junction);
$fs->removeDirectory($old_target);
$fs->junction($target, $junction);
$this->assertTrue($fs->isJunction($junction), $junction.': is a junction');
$this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
self::assertTrue($fs->isJunction($junction), $junction.': is a junction');
self::assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
}
public function testCopy(): void
@ -362,17 +362,17 @@ class FilesystemTest extends TestCase
$fs = new Filesystem();
$result1 = $fs->copy($this->workingDir . '/foo', $this->workingDir . '/foop');
$this->assertTrue($result1, 'Copying directory failed.');
$this->assertDirectoryExists($this->workingDir . '/foop', 'Not a directory: ' . $this->workingDir . '/foop');
$this->assertDirectoryExists($this->workingDir . '/foop/bar', 'Not a directory: ' . $this->workingDir . '/foop/bar');
$this->assertDirectoryExists($this->workingDir . '/foop/baz', 'Not a directory: ' . $this->workingDir . '/foop/baz');
$this->assertFileExists($this->workingDir . '/foop/foo.file', 'Not a file: ' . $this->workingDir . '/foop/foo.file');
$this->assertFileExists($this->workingDir . '/foop/bar/foobar.file', 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file');
$this->assertFileExists($this->workingDir . '/foop/baz/foobaz.file', 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file');
self::assertTrue($result1, 'Copying directory failed.');
self::assertDirectoryExists($this->workingDir . '/foop', 'Not a directory: ' . $this->workingDir . '/foop');
self::assertDirectoryExists($this->workingDir . '/foop/bar', 'Not a directory: ' . $this->workingDir . '/foop/bar');
self::assertDirectoryExists($this->workingDir . '/foop/baz', 'Not a directory: ' . $this->workingDir . '/foop/baz');
self::assertFileExists($this->workingDir . '/foop/foo.file', 'Not a file: ' . $this->workingDir . '/foop/foo.file');
self::assertFileExists($this->workingDir . '/foop/bar/foobar.file', 'Not a file: ' . $this->workingDir . '/foop/bar/foobar.file');
self::assertFileExists($this->workingDir . '/foop/baz/foobaz.file', 'Not a file: ' . $this->workingDir . '/foop/baz/foobaz.file');
$result2 = $fs->copy($this->testFile, $this->workingDir . '/testfile.file');
$this->assertTrue($result2);
$this->assertFileExists($this->workingDir . '/testfile.file');
self::assertTrue($result2);
self::assertFileExists($this->workingDir . '/testfile.file');
}
public function testCopyThenRemove(): void
@ -387,14 +387,14 @@ class FilesystemTest extends TestCase
$fs = new Filesystem();
$fs->copyThenRemove($this->testFile, $this->workingDir . '/testfile.file');
$this->assertFileDoesNotExist($this->testFile, 'Still a file: ' . $this->testFile);
self::assertFileDoesNotExist($this->testFile, 'Still a file: ' . $this->testFile);
$fs->copyThenRemove($this->workingDir . '/foo', $this->workingDir . '/foop');
$this->assertFileDoesNotExist($this->workingDir . '/foo/baz/foobaz.file', 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file');
$this->assertFileDoesNotExist($this->workingDir . '/foo/bar/foobar.file', 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file');
$this->assertFileDoesNotExist($this->workingDir . '/foo/foo.file', 'Still a file: ' . $this->workingDir . '/foo/foo.file');
$this->assertDirectoryDoesNotExist($this->workingDir . '/foo/baz', 'Still a directory: ' . $this->workingDir . '/foo/baz');
$this->assertDirectoryDoesNotExist($this->workingDir . '/foo/bar', 'Still a directory: ' . $this->workingDir . '/foo/bar');
$this->assertDirectoryDoesNotExist($this->workingDir . '/foo', 'Still a directory: ' . $this->workingDir . '/foo');
self::assertFileDoesNotExist($this->workingDir . '/foo/baz/foobaz.file', 'Still a file: ' . $this->workingDir . '/foo/baz/foobaz.file');
self::assertFileDoesNotExist($this->workingDir . '/foo/bar/foobar.file', 'Still a file: ' . $this->workingDir . '/foo/bar/foobar.file');
self::assertFileDoesNotExist($this->workingDir . '/foo/foo.file', 'Still a file: ' . $this->workingDir . '/foo/foo.file');
self::assertDirectoryDoesNotExist($this->workingDir . '/foo/baz', 'Still a directory: ' . $this->workingDir . '/foo/baz');
self::assertDirectoryDoesNotExist($this->workingDir . '/foo/bar', 'Still a directory: ' . $this->workingDir . '/foo/bar');
self::assertDirectoryDoesNotExist($this->workingDir . '/foo', 'Still a directory: ' . $this->workingDir . '/foo');
}
}