From 2992e8651a18adeddf3735218d61d8a9dde9f0a0 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Wed, 27 Oct 2021 16:18:46 +0200 Subject: [PATCH] Add types to `Util` tests (#10228) --- src/Composer/Util/Perforce.php | 2 +- src/Composer/Util/ProcessExecutor.php | 4 +- tests/Composer/Test/Util/AuthHelperTest.php | 30 ++++++++------ tests/Composer/Test/Util/BitbucketTest.php | 20 +++++++-- tests/Composer/Test/Util/FilesystemTest.php | 14 +++++++ tests/Composer/Test/Util/GitHubTest.php | 30 ++++++++------ tests/Composer/Test/Util/GitLabTest.php | 17 ++++++++ tests/Composer/Test/Util/GitTest.php | 14 +++++++ .../Test/Util/Http/ProxyHelperTest.php | 21 ++++++++++ .../Test/Util/Http/ProxyManagerTest.php | 11 +++++ .../Test/Util/Http/RequestProxyTest.php | 7 ++++ .../Composer/Test/Util/HttpDownloaderTest.php | 3 ++ tests/Composer/Test/Util/IniHelperTest.php | 5 +++ .../Composer/Test/Util/NoProxyPatternTest.php | 18 ++++++++ .../Composer/Test/Util/PackageSorterTest.php | 11 ++++- tests/Composer/Test/Util/PerforceTest.php | 38 ++++++++++++----- .../Test/Util/ProcessExecutorTest.php | 7 ++++ .../Test/Util/RemoteFilesystemTest.php | 41 ++++++++++++++++--- .../Test/Util/StreamContextFactoryTest.php | 8 ++++ tests/Composer/Test/Util/TlsHelperTest.php | 8 +++- tests/Composer/Test/Util/UrlTest.php | 8 ++++ 21 files changed, 268 insertions(+), 49 deletions(-) diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php index a9f2e3686..7d3929c94 100644 --- a/src/Composer/Util/Perforce.php +++ b/src/Composer/Util/Perforce.php @@ -296,7 +296,7 @@ class Perforce } /** - * @param string $user + * @param string|null $user * * @return void */ diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 8248aee9a..12e7796a2 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -446,7 +446,7 @@ class ProcessExecutor /** * Escapes a string to be used as a shell argument. * - * @param ?string $argument The argument that will be escaped + * @param string|false|null $argument The argument that will be escaped * * @return string The escaped argument */ @@ -466,7 +466,7 @@ class ProcessExecutor * Modified from https://github.com/johnstevenson/winbox-args * MIT Licensed (c) John Stevenson * - * @param ?string $argument + * @param string|false|null $argument * * @return string */ diff --git a/tests/Composer/Test/Util/AuthHelperTest.php b/tests/Composer/Test/Util/AuthHelperTest.php index 33f64382a..d7018cd1c 100644 --- a/tests/Composer/Test/Util/AuthHelperTest.php +++ b/tests/Composer/Test/Util/AuthHelperTest.php @@ -22,13 +22,13 @@ use Composer\Util\Bitbucket; */ class AuthHelperTest extends TestCase { - /** @type \Composer\IO\IOInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Composer\IO\IOInterface&\PHPUnit\Framework\MockObject\MockObject */ private $io; - /** @type \Composer\Config|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Composer\Config&\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @type AuthHelper */ + /** @var AuthHelper */ private $authHelper; protected function setUp() @@ -293,9 +293,11 @@ class AuthHelperTest extends TestCase /** * @dataProvider basicHttpAuthenticationProvider * - * @param string $url - * @param string $origin - * @param array $auth + * @param string $url + * @param string $origin + * @param array $auth + * + * @phpstan-param array{username: string|null, password: string|null} $auth */ public function testAddAuthenticationHeaderWithBasicHttpAuthentication($url, $origin, $auth) { @@ -358,7 +360,7 @@ class AuthHelperTest extends TestCase 'password' => 'my_password', ); - /** @var \Composer\Config\ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject $configSource */ + /** @var \Composer\Config\ConfigSourceInterface&\PHPUnit\Framework\MockObject\MockObject $configSource */ $configSource = $this ->getMockBuilder('Composer\Config\ConfigSourceInterface') ->disableOriginalConstructor() @@ -392,7 +394,7 @@ class AuthHelperTest extends TestCase $answer = 'y'; $configSourceName = 'https://api.gitlab.com/source'; - /** @var \Composer\Config\ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject $configSource */ + /** @var \Composer\Config\ConfigSourceInterface&\PHPUnit\Framework\MockObject\MockObject $configSource */ $configSource = $this ->getMockBuilder('Composer\Config\ConfigSourceInterface') ->disableOriginalConstructor() @@ -440,7 +442,7 @@ class AuthHelperTest extends TestCase $answer = 'n'; $configSourceName = 'https://api.gitlab.com/source'; - /** @var \Composer\Config\ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject $configSource */ + /** @var \Composer\Config\ConfigSourceInterface&\PHPUnit\Framework\MockObject\MockObject $configSource */ $configSource = $this ->getMockBuilder('Composer\Config\ConfigSourceInterface') ->disableOriginalConstructor() @@ -480,7 +482,7 @@ class AuthHelperTest extends TestCase $answer = 'invalid'; $configSourceName = 'https://api.gitlab.com/source'; - /** @var \Composer\Config\ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject $configSource */ + /** @var \Composer\Config\ConfigSourceInterface&\PHPUnit\Framework\MockObject\MockObject $configSource */ $configSource = $this ->getMockBuilder('Composer\Config\ConfigSourceInterface') ->disableOriginalConstructor() @@ -512,8 +514,12 @@ class AuthHelperTest extends TestCase } /** - * @param string $origin - * @param array $auth + * @param string $origin + * @param array $auth + * + * @return void + * + * @phpstan-param array{username: string|null, password: string|null} $auth */ private function expectsAuthentication($origin, $auth) { diff --git a/tests/Composer/Test/Util/BitbucketTest.php b/tests/Composer/Test/Util/BitbucketTest.php index 3182ac014..47fdb4ea8 100644 --- a/tests/Composer/Test/Util/BitbucketTest.php +++ b/tests/Composer/Test/Util/BitbucketTest.php @@ -22,21 +22,28 @@ use Composer\Test\Mock\ProcessExecutorMock; */ class BitbucketTest extends TestCase { + /** @var string */ private $username = 'username'; + /** @var string */ private $password = 'password'; + /** @var string */ private $consumer_key = 'consumer_key'; + /** @var string */ private $consumer_secret = 'consumer_secret'; + /** @var string */ private $message = 'mymessage'; + /** @var string */ private $origin = 'bitbucket.org'; + /** @var string */ private $token = 'bitbuckettoken'; - /** @type \Composer\IO\ConsoleIO|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Composer\IO\ConsoleIO&\PHPUnit\Framework\MockObject\MockObject */ private $io; - /** @type \Composer\Util\HttpDownloader|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Composer\Util\HttpDownloader&\PHPUnit\Framework\MockObject\MockObject */ private $httpDownloader; - /** @type \Composer\Config|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Composer\Config&\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @type Bitbucket */ + /** @var Bitbucket */ private $bitbucket; /** @var int */ private $time; @@ -400,6 +407,11 @@ class BitbucketTest extends TestCase $this->assertFalse($this->bitbucket->authorizeOAuthInteractively($this->origin, $this->message)); } + /** + * @param bool $removeBasicAuth + * + * @return void + */ private function setExpectationsForStoringAccessToken($removeBasicAuth = false) { $configSourceMock = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock(); diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 7ac013a78..bdf6b7f16 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -51,6 +51,12 @@ class FilesystemTest extends TestCase /** * @dataProvider providePathCouplesAsCode + * + * @param string $a + * @param string $b + * @param bool $directory + * @param string $expected + * @param bool $static */ public function testFindShortestPathCode($a, $b, $directory, $expected, $static = false) { @@ -109,6 +115,11 @@ class FilesystemTest extends TestCase /** * @dataProvider providePathCouples + * + * @param string $a + * @param string $b + * @param string $expected + * @param bool $directory */ public function testFindShortestPath($a, $b, $expected, $directory = false) { @@ -191,6 +202,9 @@ class FilesystemTest extends TestCase /** * @dataProvider provideNormalizedPaths + * + * @param string $expected + * @param string $actual */ public function testNormalizePath($expected, $actual) { diff --git a/tests/Composer/Test/Util/GitHubTest.php b/tests/Composer/Test/Util/GitHubTest.php index 1de64b67e..7a77de092 100644 --- a/tests/Composer/Test/Util/GitHubTest.php +++ b/tests/Composer/Test/Util/GitHubTest.php @@ -24,8 +24,11 @@ use RecursiveIteratorIterator; */ class GitHubTest extends TestCase { + /** @var string */ private $password = 'password'; + /** @var string */ private $message = 'mymessage'; + /** @var string */ private $origin = 'github.com'; public function testUsernamePasswordAuthenticationFlow() @@ -100,6 +103,9 @@ class GitHubTest extends TestCase $this->assertFalse($github->authorizeOAuthInteractively($this->origin)); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\ConsoleIO + */ private function getIOMock() { $io = $this @@ -111,11 +117,17 @@ class GitHubTest extends TestCase return $io; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config + */ private function getConfigMock() { return $this->getMockBuilder('Composer\Config')->getMock(); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Util\HttpDownloader + */ private function getHttpDownloaderMock() { $httpDownloader = $this @@ -127,6 +139,9 @@ class GitHubTest extends TestCase return $httpDownloader; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config\JsonConfigSource + */ private function getAuthJsonMock() { $authjson = $this @@ -143,6 +158,9 @@ class GitHubTest extends TestCase return $authjson; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config\JsonConfigSource + */ private function getConfJsonMock() { $confjson = $this @@ -158,16 +176,4 @@ class GitHubTest extends TestCase return $confjson; } - - public static function recursiveFind($array, $needle) - { - $iterator = new RecursiveArrayIterator($array); - $recursive = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST); - - foreach ($recursive as $key => $value) { - if ($key === $needle) { - return $value; - } - } - } } diff --git a/tests/Composer/Test/Util/GitLabTest.php b/tests/Composer/Test/Util/GitLabTest.php index e5ba33db6..6cbb34023 100644 --- a/tests/Composer/Test/Util/GitLabTest.php +++ b/tests/Composer/Test/Util/GitLabTest.php @@ -22,10 +22,15 @@ use Composer\Test\TestCase; */ class GitLabTest extends TestCase { + /** @var string */ private $username = 'username'; + /** @var string */ private $password = 'password'; + /** @var string */ private $message = 'mymessage'; + /** @var string */ private $origin = 'gitlab.com'; + /** @var string */ private $token = 'gitlabtoken'; public function testUsernamePasswordAuthenticationFlow() @@ -109,6 +114,9 @@ class GitLabTest extends TestCase $gitLab->authorizeOAuthInteractively('https', $this->origin); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\ConsoleIO + */ private function getIOMock() { $io = $this @@ -120,11 +128,17 @@ class GitLabTest extends TestCase return $io; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config + */ private function getConfigMock() { return $this->getMockBuilder('Composer\Config')->getMock(); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Util\HttpDownloader + */ private function getHttpDownloaderMock() { $httpDownloader = $this @@ -136,6 +150,9 @@ class GitLabTest extends TestCase return $httpDownloader; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config\JsonConfigSource + */ private function getAuthJsonMock() { $authjson = $this diff --git a/tests/Composer/Test/Util/GitTest.php b/tests/Composer/Test/Util/GitTest.php index f1df7c2f7..4dfe653be 100644 --- a/tests/Composer/Test/Util/GitTest.php +++ b/tests/Composer/Test/Util/GitTest.php @@ -43,6 +43,9 @@ class GitTest extends TestCase /** * @dataProvider publicGithubNoCredentialsProvider + * + * @param string $protocol + * @param string $expectedUrl */ public function testRunCommandPublicGitHubRepositoryNotInitialClone($protocol, $expectedUrl) { @@ -96,6 +99,12 @@ class GitTest extends TestCase /** * @dataProvider privateGithubWithCredentialsProvider + * + * @param string $gitUrl + * @param string $protocol + * @param string $gitHubToken + * @param string $expectedUrl + * @param int $expectedFailuresBeforeSuccess */ public function testRunCommandPrivateGitHubRepositoryNotInitialCloneNotInteractiveWithAuthentication($gitUrl, $protocol, $gitHubToken, $expectedUrl, $expectedFailuresBeforeSuccess) { @@ -143,6 +152,11 @@ class GitTest extends TestCase ); } + /** + * @param string $protocol + * + * @return void + */ private function mockConfig($protocol) { $this->config diff --git a/tests/Composer/Test/Util/Http/ProxyHelperTest.php b/tests/Composer/Test/Util/Http/ProxyHelperTest.php index c79ad2503..81d1d33a8 100644 --- a/tests/Composer/Test/Util/Http/ProxyHelperTest.php +++ b/tests/Composer/Test/Util/Http/ProxyHelperTest.php @@ -45,6 +45,8 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataMalformed + * + * @param string $url */ public function testThrowsOnMalformedUrl($url) { @@ -64,6 +66,9 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataFormatting + * + * @param string $url + * @param string $expected */ public function testUrlFormatting($url, $expected) { @@ -85,6 +90,10 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataCaseOverrides + * + * @param array $server + * @param string $expected + * @param int $index */ public function testLowercaseOverridesUppercase(array $server, $expected, $index) { @@ -106,6 +115,10 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataCGIOverrides + * + * @param array $server + * @param string $expected + * @param int $index */ public function testCGIUpperCaseOverridesHttp(array $server, $expected, $index) { @@ -142,6 +155,11 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataContextOptions + * + * @param string $url + * @param array $expected + * + * @phpstan-param array{http: array{proxy: string, header?: string}} $expected */ public function testGetContextOptions($url, $expected) { @@ -167,6 +185,9 @@ class ProxyHelperTest extends TestCase /** * @dataProvider dataRequestFullUri + * + * @param string $requestUrl + * @param mixed[] $expected */ public function testSetRequestFullUri($requestUrl, $expected) { diff --git a/tests/Composer/Test/Util/Http/ProxyManagerTest.php b/tests/Composer/Test/Util/Http/ProxyManagerTest.php index 1a2cc4e84..48e9914df 100644 --- a/tests/Composer/Test/Util/Http/ProxyManagerTest.php +++ b/tests/Composer/Test/Util/Http/ProxyManagerTest.php @@ -68,6 +68,13 @@ class ProxyManagerTest extends TestCase /** * @dataProvider dataRequest + * + * @param array $server + * @param string $url + * @param string $expectedUrl + * @param mixed[] $expectedOptions + * @param bool $expectedSecure + * @param string $expectedMessage */ public function testGetProxyForRequest($server, $url, $expectedUrl, $expectedOptions, $expectedSecure, $expectedMessage) { @@ -126,6 +133,10 @@ class ProxyManagerTest extends TestCase /** * @dataProvider dataStatus + * + * @param array $server + * @param bool $expectedStatus + * @param string $expectedMessage */ public function testGetStatus($server, $expectedStatus, $expectedMessage) { diff --git a/tests/Composer/Test/Util/Http/RequestProxyTest.php b/tests/Composer/Test/Util/Http/RequestProxyTest.php index 59996d87b..33f5664a8 100644 --- a/tests/Composer/Test/Util/Http/RequestProxyTest.php +++ b/tests/Composer/Test/Util/Http/RequestProxyTest.php @@ -19,6 +19,9 @@ class RequestProxyTest extends TestCase { /** * @dataProvider dataSecure + * + * @param string $url + * @param bool $expectedSecure */ public function testIsSecure($url, $expectedSecure) { @@ -39,6 +42,10 @@ class RequestProxyTest extends TestCase /** * @dataProvider dataProxyUrl + * + * @param string $url + * @param string $format + * @param string $expected */ public function testGetFormattedUrlFormat($url, $format, $expected) { diff --git a/tests/Composer/Test/Util/HttpDownloaderTest.php b/tests/Composer/Test/Util/HttpDownloaderTest.php index b65aa760a..62b601bef 100644 --- a/tests/Composer/Test/Util/HttpDownloaderTest.php +++ b/tests/Composer/Test/Util/HttpDownloaderTest.php @@ -17,6 +17,9 @@ use PHPUnit\Framework\TestCase; class HttpDownloaderTest extends TestCase { + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config + */ private function getConfigMock() { $config = $this->getMockBuilder('Composer\Config')->getMock(); diff --git a/tests/Composer/Test/Util/IniHelperTest.php b/tests/Composer/Test/Util/IniHelperTest.php index efcdbf9bb..0856cd771 100644 --- a/tests/Composer/Test/Util/IniHelperTest.php +++ b/tests/Composer/Test/Util/IniHelperTest.php @@ -91,6 +91,11 @@ class IniHelperTest extends TestCase } } + /** + * @param string[] $paths + * + * @return void + */ protected function setEnv(array $paths) { putenv('COMPOSER_ORIGINAL_INIS='.implode(PATH_SEPARATOR, $paths)); diff --git a/tests/Composer/Test/Util/NoProxyPatternTest.php b/tests/Composer/Test/Util/NoProxyPatternTest.php index d8edb462c..940eff5cc 100644 --- a/tests/Composer/Test/Util/NoProxyPatternTest.php +++ b/tests/Composer/Test/Util/NoProxyPatternTest.php @@ -19,6 +19,10 @@ class NoProxyPatternTest extends TestCase { /** * @dataProvider dataHostName + * + * @param string $noproxy + * @param string $url + * @param bool $expected */ public function testHostName($noproxy, $url, $expected) { @@ -46,6 +50,10 @@ class NoProxyPatternTest extends TestCase /** * @dataProvider dataIpAddress + * + * @param string $noproxy + * @param string $url + * @param bool $expected */ public function testIpAddress($noproxy, $url, $expected) { @@ -71,6 +79,10 @@ class NoProxyPatternTest extends TestCase /** * @dataProvider dataIpRange + * + * @param string $noproxy + * @param string $url + * @param bool $expected */ public function testIpRange($noproxy, $url, $expected) { @@ -96,6 +108,10 @@ class NoProxyPatternTest extends TestCase /** * @dataProvider dataPort + * + * @param string $noproxy + * @param string $url + * @param bool $expected */ public function testPort($noproxy, $url, $expected) { @@ -121,6 +137,8 @@ class NoProxyPatternTest extends TestCase * Appends a scheme to the test url if it is missing * * @param string $url + * + * @return string */ private function getUrl($url) { diff --git a/tests/Composer/Test/Util/PackageSorterTest.php b/tests/Composer/Test/Util/PackageSorterTest.php index 23f5996a6..7ee94982c 100644 --- a/tests/Composer/Test/Util/PackageSorterTest.php +++ b/tests/Composer/Test/Util/PackageSorterTest.php @@ -104,8 +104,9 @@ class PackageSorterTest extends TestCase /** * @dataProvider sortingOrdersDependenciesHigherThanPackageDataProvider - * @param array $packages - * @param array $expectedOrderedList + * + * @param Package[] $packages + * @param string[] $expectedOrderedList */ public function testSortingOrdersDependenciesHigherThanPackage($packages, $expectedOrderedList) { @@ -117,6 +118,12 @@ class PackageSorterTest extends TestCase self::assertSame($expectedOrderedList, $sortedPackageNames); } + /** + * @param string $name + * @param string[] $requires + * + * @return Package + */ private function createPackage($name, $requires) { $package = new Package($name, '1.0.0.0', '1.0.0'); diff --git a/tests/Composer/Test/Util/PerforceTest.php b/tests/Composer/Test/Util/PerforceTest.php index 2c862270e..d8743f3d7 100644 --- a/tests/Composer/Test/Util/PerforceTest.php +++ b/tests/Composer/Test/Util/PerforceTest.php @@ -21,9 +21,13 @@ use Composer\Util\ProcessExecutor; */ class PerforceTest extends TestCase { + /** @var Perforce */ protected $perforce; + /** @var \PHPUnit\Framework\MockObject\MockObject&\Composer\Util\ProcessExecutor */ protected $processExecutor; + /** @var array */ protected $repoConfig; + /** @var \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\IOInterface */ protected $io; const TEST_DEPOT = 'depot'; @@ -41,14 +45,9 @@ class PerforceTest extends TestCase $this->createNewPerforceWithWindowsFlag(true); } - protected function tearDown() - { - $this->perforce = null; - $this->io = null; - $this->repoConfig = null; - $this->processExecutor = null; - } - + /** + * @return array + */ public function getTestRepoConfig() { return array( @@ -59,11 +58,19 @@ class PerforceTest extends TestCase ); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\IOInterface + */ public function getMockIOInterface() { return $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } + /** + * @param bool $flag + * + * @return void + */ protected function createNewPerforceWithWindowsFlag($flag) { $this->perforce = new Perforce($this->repoConfig, self::TEST_PORT, self::TEST_PATH, $this->processExecutor, $flag, $this->io); @@ -435,7 +442,7 @@ class PerforceTest extends TestCase public function testCheckStreamWithoutStream() { - $result = $this->perforce->checkStream('depot'); + $result = $this->perforce->checkStream(); $this->assertFalse($result); $this->assertFalse($this->perforce->isStream()); } @@ -452,7 +459,7 @@ class PerforceTest extends TestCase } ) ); - $result = $this->perforce->checkStream('depot'); + $result = $this->perforce->checkStream(); $this->assertTrue($result); $this->assertTrue($this->perforce->isStream()); } @@ -653,6 +660,9 @@ class PerforceTest extends TestCase $this->assertFalse($result); } + /** + * @return string + */ public static function getComposerJson() { $composer_json = array( @@ -670,6 +680,11 @@ class PerforceTest extends TestCase return implode($composer_json); } + /** + * @param bool $withStream + * + * @return string[] + */ private function getExpectedClientSpec($withStream) { $expectedArray = array( @@ -702,6 +717,9 @@ class PerforceTest extends TestCase return $expectedArray; } + /** + * @return void + */ private function setPerforceToStream() { $this->perforce->setStream('//depot/branch'); diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 166fd4174..8375f75de 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -69,6 +69,9 @@ class ProcessExecutorTest extends TestCase /** * @dataProvider hidePasswordProvider + * + * @param string $command + * @param string $expectedCommandOutput */ public function testHidePasswords($command, $expectedCommandOutput) { @@ -133,6 +136,10 @@ class ProcessExecutorTest extends TestCase * Test various arguments are escaped as expected * * @dataProvider dataEscapeArguments + * + * @param string|false|null $argument + * @param string $win + * @param string $unix */ public function testEscapeArgument($argument, $win, $unix) { diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index 862f0167b..4233dc948 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -148,7 +148,8 @@ class RemoteFilesystemTest extends TestCase { $fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock()); - $this->assertNull($this->callCallbackGet($fs, STREAM_NOTIFY_FAILURE, 0, 'HTTP/1.1 404 Not Found', 404, 0, 0)); + $this->callCallbackGet($fs, STREAM_NOTIFY_FAILURE, 0, 'HTTP/1.1 404 Not Found', 404, 0, 0); + $this->assertTrue(true, 'callbackGet must pass through 404'); } public function testGetContents() @@ -341,7 +342,14 @@ class RemoteFilesystemTest extends TestCase $this->assertEquals(array('bitbucket.org', 'bbuseruploads.s3.amazonaws.com'), $domains); } - private function callGetOptionsForUrl($io, array $args = array(), array $options = array(), $fileUrl = '') + /** + * @param mixed[] $args + * @param mixed[] $options + * @param string $fileUrl + * + * @return mixed[] + */ + private function callGetOptionsForUrl(IOInterface $io, array $args = array(), array $options = array(), $fileUrl = '') { $fs = new RemoteFilesystem($io, $this->getConfigMock(), $options); $ref = new ReflectionMethod($fs, 'getOptionsForUrl'); @@ -373,6 +381,16 @@ class RemoteFilesystemTest extends TestCase return $config; } + /** + * @param int $notificationCode + * @param int $severity + * @param string $message + * @param int $messageCode + * @param int $bytesTransferred + * @param int $bytesMax + * + * @return void + */ private function callCallbackGet(RemoteFilesystem $fs, $notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax) { $ref = new ReflectionMethod($fs, 'callbackGet'); @@ -380,6 +398,13 @@ class RemoteFilesystemTest extends TestCase $ref->invoke($fs, $notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax); } + /** + * @param object|string $object + * @param string $attribute + * @param mixed $value + * + * @return void + */ private function setAttribute($object, $attribute, $value) { $attr = new ReflectionProperty($object, $attribute); @@ -387,6 +412,13 @@ class RemoteFilesystemTest extends TestCase $attr->setValue($object, $value); } + /** + * @param mixed $value + * @param string $attribute + * @param object|string $object + * + * @return void + */ private function assertAttributeEqualsCustom($value, $attribute, $object) { $attr = new ReflectionProperty($object, $attribute); @@ -403,8 +435,7 @@ class RemoteFilesystemTest extends TestCase } /** - * @param array $mockedMethods - * @param AuthHelper $authHelper + * @param string[] $mockedMethods * * @return RemoteFilesystem|MockObject */ @@ -423,7 +454,7 @@ class RemoteFilesystemTest extends TestCase } /** - * @param array $mockedMethods + * @param string[] $mockedMethods * * @return AuthHelper|MockObject */ diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index c28b95b1a..7b2428ec1 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -32,6 +32,11 @@ class StreamContextFactoryTest extends TestCase /** * @dataProvider dataGetContext + * + * @param mixed[] $expectedOptions + * @param mixed[] $defaultOptions + * @param mixed[] $expectedParams + * @param mixed[] $defaultParams */ public function testGetContext($expectedOptions, $defaultOptions, $expectedParams, $defaultParams) { @@ -157,6 +162,9 @@ class StreamContextFactoryTest extends TestCase /** * @dataProvider dataSSLProxy + * + * @param string $expected + * @param string $proxy */ public function testSSLProxy($expected, $proxy) { diff --git a/tests/Composer/Test/Util/TlsHelperTest.php b/tests/Composer/Test/Util/TlsHelperTest.php index df0cdd3bf..84c826178 100644 --- a/tests/Composer/Test/Util/TlsHelperTest.php +++ b/tests/Composer/Test/Util/TlsHelperTest.php @@ -17,7 +17,13 @@ use Composer\Test\TestCase; class TlsHelperTest extends TestCase { - /** @dataProvider dataCheckCertificateHost */ + /** + * @dataProvider dataCheckCertificateHost + * + * @param bool $expectedResult + * @param string $hostname + * @param string[] $certNames + */ public function testCheckCertificateHost($expectedResult, $hostname, $certNames) { $certificate['subject']['commonName'] = $expectedCn = array_shift($certNames); diff --git a/tests/Composer/Test/Util/UrlTest.php b/tests/Composer/Test/Util/UrlTest.php index 5b76dc9e8..66165b4b8 100644 --- a/tests/Composer/Test/Util/UrlTest.php +++ b/tests/Composer/Test/Util/UrlTest.php @@ -20,6 +20,11 @@ class UrlTest extends TestCase { /** * @dataProvider distRefsProvider + * + * @param string $url + * @param string $expectedUrl + * @param array $conf + * @param string $ref */ public function testUpdateDistReference($url, $expectedUrl, $conf = array(), $ref = 'newref') { @@ -61,6 +66,9 @@ class UrlTest extends TestCase /** * @dataProvider sanitizeProvider + * + * @param string $expected + * @param string $url */ public function testSanitize($expected, $url) {