1
0
Fork 0

Finalize phpstan level 6 for tests dir, closes #10159

pull/10257/head
Jordi Boggiano 2021-11-02 14:32:09 +01:00
parent a86046f9e4
commit cb0293cf30
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
20 changed files with 136 additions and 17 deletions

View File

@ -9,3 +9,8 @@ parameters:
message: "#^Parameter \\#2 \\$capabilityClassName of method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\) expects class\\-string\\<Composer\\\\Plugin\\\\Capability\\\\Capability\\>, string given\\.$#"
count: 2
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
-
message: "#^Unable to resolve the template type CapabilityClass in call to method Composer\\\\Plugin\\\\PluginManager::getPluginCapability\\(\\)$#"
count: 2
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php

View File

@ -3,7 +3,7 @@ includes:
- ./baseline.neon
parameters:
level: 5
level: 6
excludePaths:
- '../tests/Composer/Test/Fixtures/*'

View File

@ -102,6 +102,7 @@ class AllFunctionalTest extends TestCase
/**
* @dataProvider getTestFiles
* @depends testBuildPhar
* @param string $testFile
*/
public function testIntegration($testFile)
{

View File

@ -87,6 +87,10 @@ class ApplicationTest extends TestCase
$application->doRun($inputMock, $outputMock);
}
/**
* @param string $command
* @return void
*/
public function ensureNoDevWarning($command)
{
$application = new Application;

View File

@ -27,6 +27,8 @@ class ClassMapGeneratorTest extends TestCase
{
/**
* @dataProvider getTestCreateMapTests
* @param string $directory
* @param array<string, string> $expected
*/
public function testCreateMap($directory, $expected)
{

View File

@ -17,10 +17,15 @@ use Composer\Util\Filesystem;
class CacheTest extends TestCase
{
/** @var string[] */
private $files;
/** @var string */
private $root;
/** @var \Symfony\Component\Finder\Finder&\PHPUnit\Framework\MockObject\MockObject */
private $finder;
/** @var Filesystem&\PHPUnit\Framework\MockObject\MockObject */
private $filesystem;
/** @var Cache&\PHPUnit\Framework\MockObject\MockObject */
private $cache;
public function setUp()
@ -108,7 +113,7 @@ class CacheTest extends TestCase
public function testClearCache()
{
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->cache = new Cache($io, $this->root, 'a-z0-9.', $this->filesystem);
$this->assertTrue($this->cache->clear());
$cache = new Cache($io, $this->root, 'a-z0-9.', $this->filesystem);
$this->assertTrue($cache->clear());
}
}

View File

@ -18,6 +18,9 @@ class ConfigTest extends TestCase
{
/**
* @dataProvider dataAddPackagistRepository
* @param mixed[] $expected
* @param mixed[] $localConfig
* @param ?mixed[] $systemConfig
*/
public function testAddPackagistRepository($expected, $localConfig, $systemConfig = null)
{
@ -265,7 +268,7 @@ class ConfigTest extends TestCase
}
/**
* @return array List of test URLs that should pass strict security
* @return string[][] List of test URLs that should pass strict security
*/
public function allowedUrlProvider()
{
@ -286,7 +289,7 @@ class ConfigTest extends TestCase
}
/**
* @return array List of test URLs that should not pass strict security
* @return string[][] List of test URLs that should not pass strict security
*/
public function prohibitedUrlProvider()
{

View File

@ -29,6 +29,13 @@ class PoolBuilderTest extends TestCase
{
/**
* @dataProvider getIntegrationTests
* @param string $file
* @param string $message
* @param mixed[] $expect
* @param mixed[] $root
* @param mixed[] $requestData
* @param mixed[] $packageRepos
* @param mixed[] $fixed
*/
public function testPoolBuilder($file, $message, $expect, $root, $requestData, $packageRepos, $fixed)
{

View File

@ -91,6 +91,7 @@ class ArchiveDownloaderTest extends TestCase
/**
* @dataProvider provideUrls
* @param string $url
*/
public function testProcessUrlRewriteDist($url)
{
@ -128,6 +129,8 @@ class ArchiveDownloaderTest extends TestCase
/**
* @dataProvider provideBitbucketUrls
* @param string $url
* @param string $extension
*/
public function testProcessUrlRewriteBitbucketDist($url, $extension)
{
@ -160,6 +163,9 @@ class ArchiveDownloaderTest extends TestCase
);
}
/**
* @return \Composer\Downloader\ArchiveDownloader&\PHPUnit\Framework\MockObject\MockObject
*/
private function getArchiveDownloaderMock()
{
return $this->getMockForAbstractClass(

View File

@ -632,6 +632,11 @@ class DownloadManagerTest extends TestCase
/**
* @dataProvider updatesProvider
* @param ?string $prevPkgSource
* @param ?bool $prevPkgIsDev
* @param string[] $targetAvailable
* @param bool $targetIsDev
* @param string[] $expected
*/
public function testGetAvailableSourcesUpdateSticksToSameSource($prevPkgSource, $prevPkgIsDev, $targetAvailable, $targetIsDev, $expected)
{

View File

@ -40,6 +40,7 @@ class FossilDownloaderTest extends TestCase
* @param \Composer\Config $config
* @param \Composer\Test\Mock\ProcessExecutorMock $executor
* @param \Composer\Util\Filesystem $filesystem
* @return FossilDownloader
*/
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
{

View File

@ -79,6 +79,7 @@ class GitDownloaderTest extends TestCase
* @param \Composer\Config $config
* @param \Composer\Test\Mock\ProcessExecutorMock $executor
* @param \Composer\Util\Filesystem $filesystem
* @return GitDownloader
*/
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
{
@ -238,6 +239,9 @@ class GitDownloaderTest extends TestCase
/**
* @dataProvider pushUrlProvider
* @param string[] $protocols
* @param string $url
* @param string $pushUrl
*/
public function testDownloadAndSetPushUrlUseCustomVariousProtocolsForGithub($protocols, $url, $pushUrl)
{

View File

@ -40,6 +40,7 @@ class HgDownloaderTest extends TestCase
* @param \Composer\Config $config
* @param \Composer\Test\Mock\ProcessExecutorMock $executor
* @param \Composer\Util\Filesystem $filesystem
* @return HgDownloader
*/
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
{

View File

@ -62,6 +62,9 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider isInstalledProvider
* @param bool $expected
* @param string $name
* @param bool $includeDevRequirements
*/
public function testIsInstalled($expected, $name, $includeDevRequirements = true)
{
@ -84,6 +87,9 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider satisfiesProvider
* @param bool $expected
* @param string $name
* @param string $constraint
*/
public function testSatisfies($expected, $name, $constraint)
{
@ -122,6 +128,8 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider getVersionRangesProvider
* @param string $expected
* @param string $name
*/
public function testGetVersionRanges($expected, $name)
{
@ -144,6 +152,8 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider getVersionProvider
* @param ?string $expected
* @param string $name
*/
public function testGetVersion($expected, $name)
{
@ -166,6 +176,8 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider getPrettyVersionProvider
* @param ?string $expected
* @param string $name
*/
public function testGetPrettyVersion($expected, $name)
{
@ -219,6 +231,8 @@ class InstalledVersionsTest extends TestCase
/**
* @dataProvider getReferenceProvider
* @param ?string $expected
* @param string $name
*/
public function testGetReference($expected, $name)
{

View File

@ -19,14 +19,17 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Composer\IO\BufferIO;
use Composer\Config;
use Composer\Json\JsonFile;
use Composer\Package\Dumper\ArrayDumper;
use Composer\Util\Filesystem;
use Composer\Repository\ArrayRepository;
use Composer\Repository\RepositoryManager;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\InstalledArrayRepository;
use Composer\Package\RootPackageInterface;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\Link;
use Composer\Package\Locker;
use Composer\Test\Mock\FactoryMock;
@ -39,7 +42,9 @@ use Symfony\Component\Console\Formatter\OutputFormatter;
class InstallerTest extends TestCase
{
/** @var string */
protected $prevCwd;
/** @var ?string */
protected $tempComposerHome;
public function setUp()
@ -60,6 +65,8 @@ class InstallerTest extends TestCase
/**
* @dataProvider provideInstaller
* @param RootPackageInterface&BasePackage $rootPackage
* @param RepositoryInterface[] $repositories
* @param array[] $options
*/
public function testInstaller(RootPackageInterface $rootPackage, $repositories, array $options)
{
@ -143,6 +150,10 @@ class InstallerTest extends TestCase
$this->assertSame($expectedUninstalled, $uninstalled);
}
/**
* @param PackageInterface[] $packages
* @return mixed[]
*/
protected function makePackagesComparable($packages)
{
$dumper = new ArrayDumper();
@ -205,7 +216,19 @@ class InstallerTest extends TestCase
/**
* @group slow
* @dataProvider getSlowIntegrationTests
* @dataProvider provideSlowIntegrationTests
* @param string $file
* @param string $message
* @param ?string $condition
* @param Config $composerConfig
* @param ?mixed[] $lock
* @param ?mixed[] $installed
* @param string $run
* @param mixed[]|false $expectLock
* @param ?mixed[] $expectInstalled
* @param ?string $expectOutput
* @param string $expect
* @param int|string $expectResult
*/
public function testSlowIntegration($file, $message, $condition, $composerConfig, $lock, $installed, $run, $expectLock, $expectInstalled, $expectOutput, $expect, $expectResult)
{
@ -213,7 +236,19 @@ class InstallerTest extends TestCase
}
/**
* @dataProvider getIntegrationTests
* @dataProvider provideIntegrationTests
* @param string $file
* @param string $message
* @param ?string $condition
* @param Config $composerConfig
* @param ?mixed[] $lock
* @param ?mixed[] $installed
* @param string $run
* @param mixed[]|false $expectLock
* @param ?mixed[] $expectInstalled
* @param ?string $expectOutput
* @param string $expect
* @param int|string $expectResult
*/
public function testIntegration($file, $message, $condition, $composerConfig, $lock, $installed, $run, $expectLock, $expectInstalled, $expectOutput, $expect, $expectResult)
{
@ -408,16 +443,20 @@ class InstallerTest extends TestCase
}
}
public function getSlowIntegrationTests()
public function provideSlowIntegrationTests()
{
return $this->loadIntegrationTests('installer-slow/');
}
public function getIntegrationTests()
public function provideIntegrationTests()
{
return $this->loadIntegrationTests('installer/');
}
/**
* @param string $path
* @return mixed[]
*/
public function loadIntegrationTests($path)
{
$fixturesDir = realpath(__DIR__.'/Fixtures/'.$path);
@ -499,6 +538,10 @@ class InstallerTest extends TestCase
return $tests;
}
/**
* @param string $fixturesDir
* @return mixed[]
*/
protected function readTestFile(\SplFileInfo $file, $fixturesDir)
{
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), -1, PREG_SPLIT_DELIM_CAPTURE);

View File

@ -19,6 +19,11 @@ class JsonManipulatorTest extends TestCase
{
/**
* @dataProvider linkProvider
* @param string $json
* @param string $type
* @param string $package
* @param string $constraint
* @param string $expected
*/
public function testAddLink($json, $type, $package, $constraint, $expected)
{
@ -1289,6 +1294,12 @@ class JsonManipulatorTest extends TestCase
/**
* @dataProvider providerAddLinkAndSortPackages
* @param string $json
* @param string $type
* @param string $package
* @param string $constraint
* @param bool $sortPackages
* @param string $expected
*/
public function testAddLinkAndSortPackages($json, $type, $package, $constraint, $sortPackages, $expected)
{
@ -1369,6 +1380,10 @@ class JsonManipulatorTest extends TestCase
/**
* @dataProvider removeSubNodeProvider
* @param string $json
* @param string $name
* @param string $expected
* @param ?string $expectedContent
*/
public function testRemoveSubNode($json, $name, $expected, $expectedContent = null)
{

View File

@ -19,6 +19,8 @@ class JsonValidationExceptionTest extends TestCase
{
/**
* @dataProvider errorProvider
* @param string|null $message
* @param string[]|null $errors
*/
public function testGetErrors($message, $errors)
{

View File

@ -71,6 +71,9 @@ class HhvmDetectorTest extends TestCase
self::assertSame(self::getVersionParser()->normalize($version), self::getVersionParser()->normalize($detectedVersion));
}
/**
* @return ?string
*/
private static function versionIdToVersion()
{
if (!defined('HHVM_VERSION_ID')) {

View File

@ -27,7 +27,7 @@ class VersionTest extends TestCase
* 2) git log --pretty=%h --all -- crypto/opensslv.h include/openssl/opensslv.h | while read hash ; do (git show $hash:crypto/opensslv.h; git show $hash:include/openssl/opensslv.h) | grep "define OPENSSL_VERSION_TEXT" ; done > versions.txt
* 3) cat versions.txt | awk -F "OpenSSL " '{print $2}' | awk -F " " '{print $1}' | sed -e "s:\([0-9]*\.[0-9]*\.[0-9]*\):1.2.3:g" -e "s:1\.2\.3[a-z]\(-.*\)\{0,1\}$:1.2.3a\1:g" -e "s:1\.2\.3[a-z]\{2\}\(-.*\)\{0,1\}$:1.2.3zh\1:g" -e "s:beta[0-9]:beta3:g" -e "s:pre[0-9]*:pre2:g" | sort | uniq
*/
public static function getOpenSslVersions()
public static function provideOpenSslVersions()
{
return array(
// Generated
@ -73,7 +73,7 @@ class VersionTest extends TestCase
}
/**
* @dataProvider getOpenSslVersions
* @dataProvider provideOpenSslVersions
* @param string $input
* @param string $parsedVersion
* @param bool $fipsExpected
@ -88,7 +88,7 @@ class VersionTest extends TestCase
self::assertSame($normalizedVersion, $this->getVersionParser()->normalize($parsedVersion));
}
public function getLibJpegVersions()
public function provideLibJpegVersions()
{
return array(
array('9', '9.0'),
@ -100,7 +100,7 @@ class VersionTest extends TestCase
}
/**
* @dataProvider getLibJpegVersions
* @dataProvider provideLibJpegVersions
* @param string $input
* @param string $parsedVersion
*/
@ -109,7 +109,7 @@ class VersionTest extends TestCase
self::assertSame($parsedVersion, Version::parseLibjpeg($input));
}
public function getZoneinfoVersions()
public function provideZoneinfoVersions()
{
return array(
array('2019c', '2019.3'),
@ -120,7 +120,7 @@ class VersionTest extends TestCase
}
/**
* @dataProvider getZoneinfoVersions
* @dataProvider provideZoneinfoVersions
* @param string $input
* @param string $parsedVersion
*/

View File

@ -353,7 +353,6 @@ class PluginInstallerTest extends TestCase
{
$plugin = $this->getMockBuilder('Composer\Plugin\PluginInterface')
->getMock();
/** @phpstan-ignore-next-line */
$this->assertNull($this->pm->getPluginCapability($plugin, 'Fake\Ability'));
}
@ -442,7 +441,6 @@ class PluginInstallerTest extends TestCase
return array();
}));
/** @phpstan-ignore-next-line */
$this->assertNull($this->pm->getPluginCapability($plugin, $capabilityApi));
}