Fix deprecation warnings with strpos receiving null
parent
0b09e08f4b
commit
5062619046
|
@ -69,7 +69,7 @@ class GitDownloaderTest extends TestCase
|
||||||
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
|
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
|
||||||
{
|
{
|
||||||
$io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
$io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||||
$executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
|
$filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
|
||||||
$config = $this->setupConfig($config);
|
$config = $this->setupConfig($config);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class GitDownloaderTest extends TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('dev-master'));
|
->will($this->returnValue('dev-master'));
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer -- 'https://example.com/composer/composer' && git fetch composer && git remote set-url origin -- 'https://example.com/composer/composer' && git remote set-url composer -- 'https://example.com/composer/composer'");
|
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer -- 'https://example.com/composer/composer' && git fetch composer && git remote set-url origin -- 'https://example.com/composer/composer' && git remote set-url composer -- 'https://example.com/composer/composer'");
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
|
@ -147,7 +147,7 @@ class GitDownloaderTest extends TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('dev-master'));
|
->will($this->returnValue('dev-master'));
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
|
|
||||||
$this->initGitVersion('2.17.0');
|
$this->initGitVersion('2.17.0');
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ class GitDownloaderTest extends TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute', 'getErrorOutput'))->getMock();
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- 'https://github.com/mirrors/composer' 'composerPath' && cd 'composerPath' && git remote add composer -- 'https://github.com/mirrors/composer' && git fetch composer && git remote set-url origin -- 'https://github.com/mirrors/composer' && git remote set-url composer -- 'https://github.com/mirrors/composer'");
|
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- 'https://github.com/mirrors/composer' 'composerPath' && cd 'composerPath' && git remote add composer -- 'https://github.com/mirrors/composer' && git fetch composer && git remote set-url origin -- 'https://github.com/mirrors/composer' && git remote set-url composer -- 'https://github.com/mirrors/composer'");
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
|
@ -297,7 +297,7 @@ class GitDownloaderTest extends TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getPrettyVersion')
|
->method('getPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
|
|
||||||
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- '{$url}' 'composerPath' && cd 'composerPath' && git remote add composer -- '{$url}' && git fetch composer && git remote set-url origin -- '{$url}' && git remote set-url composer -- '{$url}'");
|
$expectedGitCommand = $this->winCompat("git clone --no-checkout -- '{$url}' 'composerPath' && cd 'composerPath' && git remote add composer -- '{$url}' && git fetch composer && git remote set-url origin -- '{$url}' && git remote set-url composer -- '{$url}'");
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
|
@ -335,7 +335,7 @@ class GitDownloaderTest extends TestCase
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceUrls')
|
->method('getSourceUrls')
|
||||||
->will($this->returnValue(array('https://example.com/composer/composer')));
|
->will($this->returnValue(array('https://example.com/composer/composer')));
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
|
@ -423,7 +423,7 @@ class GitDownloaderTest extends TestCase
|
||||||
->method('getVersion')
|
->method('getVersion')
|
||||||
->will($this->returnValue('1.0.0.0'));
|
->will($this->returnValue('1.0.0.0'));
|
||||||
|
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($this->winCompat("git show-ref --head -d")))
|
->with($this->equalTo($this->winCompat("git show-ref --head -d")))
|
||||||
|
@ -589,7 +589,7 @@ composer https://github.com/old/url (push)
|
||||||
->method('getFullPrettyVersion')
|
->method('getFullPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
|
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$processExecutor->expects($this->any())
|
$processExecutor->expects($this->any())
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
@ -631,7 +631,7 @@ composer https://github.com/old/url (push)
|
||||||
->method('getVersion')
|
->method('getVersion')
|
||||||
->will($this->returnValue('dev-ref2'));
|
->will($this->returnValue('dev-ref2'));
|
||||||
|
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$processExecutor->expects($this->any())
|
$processExecutor->expects($this->any())
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
@ -654,7 +654,7 @@ composer https://github.com/old/url (push)
|
||||||
$expectedGitResetCommand = $this->winCompat("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
$expectedGitResetCommand = $this->winCompat("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
||||||
|
|
||||||
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->setMethods(array('execute'))->getMock();
|
||||||
$processExecutor->expects($this->any())
|
$processExecutor->expects($this->any())
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitResetCommand))
|
->with($this->equalTo($expectedGitResetCommand))
|
||||||
|
|
|
@ -270,42 +270,17 @@ class VersionSelectorTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider getRecommendedRequireVersionPackages
|
* @dataProvider getRecommendedRequireVersionPackages
|
||||||
*/
|
*/
|
||||||
public function testFindRecommendedRequireVersion($prettyVersion, $isDev, $stability, $expectedVersion, $branchAlias = null, $packageName = null)
|
public function testFindRecommendedRequireVersion($prettyVersion, $expectedVersion, $branchAlias = null, $packageName = 'foo/bar')
|
||||||
{
|
{
|
||||||
$repositorySet = $this->createMockRepositorySet();
|
$repositorySet = $this->createMockRepositorySet();
|
||||||
$versionSelector = new VersionSelector($repositorySet);
|
$versionSelector = new VersionSelector($repositorySet);
|
||||||
$versionParser = new VersionParser();
|
$versionParser = new VersionParser();
|
||||||
|
|
||||||
$package = $this->getMockBuilder('\Composer\Package\PackageInterface')->getMock();
|
$package = new Package($packageName, $versionParser->normalize($prettyVersion), $prettyVersion);
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('getPrettyVersion')
|
|
||||||
->will($this->returnValue($prettyVersion));
|
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('getName')
|
|
||||||
->will($this->returnValue($packageName));
|
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('getVersion')
|
|
||||||
->will($this->returnValue($versionParser->normalize($prettyVersion)));
|
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('isDev')
|
|
||||||
->will($this->returnValue($isDev));
|
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('getStability')
|
|
||||||
->will($this->returnValue($stability));
|
|
||||||
$package
|
|
||||||
->expects($this->any())
|
|
||||||
->method('getTransportOptions')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
|
|
||||||
$branchAlias = $branchAlias === null ? array() : array('branch-alias' => array($prettyVersion => $branchAlias));
|
if ($branchAlias) {
|
||||||
$package->expects($this->any())
|
$package->setExtra(array('branch-alias' => array($prettyVersion => $branchAlias)));
|
||||||
->method('getExtra')
|
}
|
||||||
->will($this->returnValue($branchAlias));
|
|
||||||
|
|
||||||
$recommended = $versionSelector->findRecommendedRequireVersion($package);
|
$recommended = $versionSelector->findRecommendedRequireVersion($package);
|
||||||
|
|
||||||
|
@ -316,40 +291,40 @@ class VersionSelectorTest extends TestCase
|
||||||
public function getRecommendedRequireVersionPackages()
|
public function getRecommendedRequireVersionPackages()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
// real version, is dev package, stability, expected recommendation, [branch-alias], [pkg name]
|
// real version, expected recommendation, [branch-alias], [pkg name]
|
||||||
array('1.2.1', false, 'stable', '^1.2'),
|
array('1.2.1', '^1.2'),
|
||||||
array('1.2', false, 'stable', '^1.2'),
|
array('1.2', '^1.2'),
|
||||||
array('v1.2.1', false, 'stable', '^1.2'),
|
array('v1.2.1', '^1.2'),
|
||||||
array('3.1.2-pl2', false, 'stable', '^3.1'),
|
array('3.1.2-pl2', '^3.1'),
|
||||||
array('3.1.2-patch', false, 'stable', '^3.1'),
|
array('3.1.2-patch', '^3.1'),
|
||||||
array('2.0-beta.1', false, 'beta', '^2.0@beta'),
|
array('2.0-beta.1', '^2.0@beta'),
|
||||||
array('3.1.2-alpha5', false, 'alpha', '^3.1@alpha'),
|
array('3.1.2-alpha5', '^3.1@alpha'),
|
||||||
array('3.0-RC2', false, 'RC', '^3.0@RC'),
|
array('3.0-RC2', '^3.0@RC'),
|
||||||
array('0.1.0', false, 'stable', '^0.1.0'),
|
array('0.1.0', '^0.1.0'),
|
||||||
array('0.1.3', false, 'stable', '^0.1.3'),
|
array('0.1.3', '^0.1.3'),
|
||||||
array('0.0.3', false, 'stable', '^0.0.3'),
|
array('0.0.3', '^0.0.3'),
|
||||||
array('0.0.3-alpha', false, 'alpha', '^0.0.3@alpha'),
|
array('0.0.3-alpha', '^0.0.3@alpha'),
|
||||||
// date-based versions are not touched at all
|
// date-based versions are not touched at all
|
||||||
array('v20121020', false, 'stable', 'v20121020'),
|
array('v20121020', 'v20121020'),
|
||||||
array('v20121020.2', false, 'stable', 'v20121020.2'),
|
array('v20121020.2', 'v20121020.2'),
|
||||||
// dev packages without alias are not touched at all
|
// dev packages without alias are not touched at all
|
||||||
array('dev-master', true, 'dev', 'dev-master'),
|
array('dev-master', 'dev-master'),
|
||||||
array('3.1.2-dev', true, 'dev', '3.1.2-dev'),
|
array('3.1.2-dev', '3.1.2-dev'),
|
||||||
// dev packages with alias inherit the alias
|
// dev packages with alias inherit the alias
|
||||||
array('dev-master', true, 'dev', '^2.1@dev', '2.1.x-dev'),
|
array('dev-master', '^2.1@dev', '2.1.x-dev'),
|
||||||
array('dev-master', true, 'dev', '^2.1@dev', '2.1-dev'),
|
array('dev-master', '^2.1@dev', '2.1-dev'),
|
||||||
array('dev-master', true, 'dev', '^2.1@dev', '2.1.3.x-dev'),
|
array('dev-master', '^2.1@dev', '2.1.3.x-dev'),
|
||||||
array('dev-master', true, 'dev', '^2.0@dev', '2.x-dev'),
|
array('dev-master', '^2.0@dev', '2.x-dev'),
|
||||||
array('dev-master', true, 'dev', '^0.3.0@dev', '0.3.x-dev'),
|
array('dev-master', '^0.3.0@dev', '0.3.x-dev'),
|
||||||
array('dev-master', true, 'dev', '^0.0.3@dev', '0.0.3.x-dev'),
|
array('dev-master', '^0.0.3@dev', '0.0.3.x-dev'),
|
||||||
array('dev-master', true, 'dev', 'dev-master', VersionParser::DEFAULT_BRANCH_ALIAS),
|
array('dev-master', 'dev-master', VersionParser::DEFAULT_BRANCH_ALIAS),
|
||||||
// numeric alias
|
// numeric alias
|
||||||
array('3.x-dev', true, 'dev', '^3.0@dev', '3.0.x-dev'),
|
array('3.x-dev', '^3.0@dev', '3.0.x-dev'),
|
||||||
array('3.x-dev', true, 'dev', '^3.0@dev', '3.0-dev'),
|
array('3.x-dev', '^3.0@dev', '3.0-dev'),
|
||||||
// ext in sync with php
|
// ext in sync with php
|
||||||
array(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION, false, 'stable', '*', null, 'ext-filter'),
|
array(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION, '*', null, 'ext-filter'),
|
||||||
// ext versioned individually
|
// ext versioned individually
|
||||||
array('3.0.5', false, 'stable', '^3.0', null, 'ext-xdebug'),
|
array('3.0.5', '^3.0', null, 'ext-xdebug'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue