Add types to `Util` tests (#10228)
parent
d51c7685da
commit
2992e8651a
|
@ -296,7 +296,7 @@ class Perforce
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string|null $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -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 <john-stevenson@blueyonder.co.uk>
|
||||
*
|
||||
* @param ?string $argument
|
||||
* @param string|false|null $argument
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -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()
|
||||
|
@ -295,7 +295,9 @@ class AuthHelperTest extends TestCase
|
|||
*
|
||||
* @param string $url
|
||||
* @param string $origin
|
||||
* @param array $auth
|
||||
* @param array<string, string|null> $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()
|
||||
|
@ -513,7 +515,11 @@ class AuthHelperTest extends TestCase
|
|||
|
||||
/**
|
||||
* @param string $origin
|
||||
* @param array $auth
|
||||
* @param array<string, string|null> $auth
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @phpstan-param array{username: string|null, password: string|null} $auth
|
||||
*/
|
||||
private function expectsAuthentication($origin, $auth)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<string, mixed> $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<string, mixed> $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<string, string> $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)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,13 @@ class ProxyManagerTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider dataRequest
|
||||
*
|
||||
* @param array<string, mixed> $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<string, mixed> $server
|
||||
* @param bool $expectedStatus
|
||||
* @param string $expectedMessage
|
||||
*/
|
||||
public function testGetStatus($server, $expectedStatus, $expectedMessage)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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<string, string> */
|
||||
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<string, string>
|
||||
*/
|
||||
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');
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,6 +20,11 @@ class UrlTest extends TestCase
|
|||
{
|
||||
/**
|
||||
* @dataProvider distRefsProvider
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $expectedUrl
|
||||
* @param array<string, mixed> $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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue