1
0
Fork 0

Remove use of deprecated getMock method

pull/7088/merge
Jordi Boggiano 2018-04-12 10:24:56 +02:00
parent 036fc44c25
commit 066351c5b9
42 changed files with 279 additions and 272 deletions

View File

@ -22,8 +22,8 @@ class ApplicationTest extends TestCase
{ {
$application = new Application; $application = new Application;
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$index = 0; $index = 0;
$inputMock->expects($this->at($index++)) $inputMock->expects($this->at($index++))
@ -75,8 +75,8 @@ class ApplicationTest extends TestCase
$application->add(new \Composer\Command\SelfUpdateCommand); $application->add(new \Composer\Command\SelfUpdateCommand);
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$index = 0; $index = 0;
$inputMock->expects($this->at($index++)) $inputMock->expects($this->at($index++))

View File

@ -93,7 +93,7 @@ class AutoloadGeneratorTest extends TestCase
$this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload'; $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload';
$this->ensureDirectoryExistsAndClear($this->vendorDir); $this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->config = $this->getMock('Composer\Config'); $this->config = $this->getMockBuilder('Composer\Config')->getMock();
$this->configValueMap = array( $this->configValueMap = array(
'vendor-dir' => function () use ($that) { 'vendor-dir' => function () use ($that) {
@ -128,7 +128,7 @@ class AutoloadGeneratorTest extends TestCase
return $that->vendorDir.'/'.$package->getName() . ($targetDir ? '/'.$targetDir : ''); return $that->vendorDir.'/'.$package->getName() . ($targetDir ? '/'.$targetDir : '');
})); }));
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
$this->eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $this->eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -35,12 +35,11 @@ class CacheTest extends TestCase
$this->finder = $this->getMockBuilder('Symfony\Component\Finder\Finder')->disableOriginalConstructor()->getMock(); $this->finder = $this->getMockBuilder('Symfony\Component\Finder\Finder')->disableOriginalConstructor()->getMock();
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->cache = $this->getMock( $this->cache = $this->getMockBuilder('Composer\Cache')
'Composer\Cache', ->setMethods(array('getFinder'))
array('getFinder'), ->setConstructorArgs(array($io, $this->root))
array($io, $this->root) ->getMock();
);
$this->cache $this->cache
->expects($this->any()) ->expects($this->any())
->method('getFinder') ->method('getFinder')

View File

@ -28,7 +28,7 @@ class RunScriptCommandTest extends TestCase
{ {
$scriptName = 'testScript'; $scriptName = 'testScript';
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$input $input
->method('getOption') ->method('getOption')
->will($this->returnValueMap(array( ->will($this->returnValueMap(array(
@ -48,7 +48,7 @@ class RunScriptCommandTest extends TestCase
->with('command') ->with('command')
->willReturn(false); ->willReturn(false);
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$expectedDevMode = $dev || !$noDev; $expectedDevMode = $dev || !$noDev;

View File

@ -20,7 +20,7 @@ class ComposerTest extends TestCase
public function testSetGetPackage() public function testSetGetPackage()
{ {
$composer = new Composer(); $composer = new Composer();
$package = $this->getMock('Composer\Package\RootPackageInterface'); $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$composer->setPackage($package); $composer->setPackage($package);
$this->assertSame($package, $composer->getPackage()); $this->assertSame($package, $composer->getPackage());
@ -47,8 +47,8 @@ class ComposerTest extends TestCase
public function testSetGetDownloadManager() public function testSetGetDownloadManager()
{ {
$composer = new Composer(); $composer = new Composer();
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$manager = $this->getMock('Composer\Downloader\DownloadManager', array(), array($io)); $manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')->setConstructorArgs(array($io))->getMock();
$composer->setDownloadManager($manager); $composer->setDownloadManager($manager);
$this->assertSame($manager, $composer->getDownloadManager()); $this->assertSame($manager, $composer->getDownloadManager());
@ -57,7 +57,7 @@ class ComposerTest extends TestCase
public function testSetGetInstallationManager() public function testSetGetInstallationManager()
{ {
$composer = new Composer(); $composer = new Composer();
$manager = $this->getMock('Composer\Installer\InstallationManager'); $manager = $this->getMockBuilder('Composer\Installer\InstallationManager')->getMock();
$composer->setInstallationManager($manager); $composer->setInstallationManager($manager);
$this->assertSame($manager, $composer->getInstallationManager()); $this->assertSame($manager, $composer->getInstallationManager());

View File

@ -18,13 +18,13 @@ class ArchiveDownloaderTest extends TestCase
{ {
public function testGetFileName() public function testGetFileName()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue('http://example.com/script.js')) ->will($this->returnValue('http://example.com/script.js'))
; ;
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'getFileName'); $method = new \ReflectionMethod($downloader, 'getFileName');
$method->setAccessible(true); $method->setAccessible(true);
@ -39,12 +39,12 @@ class ArchiveDownloaderTest extends TestCase
$this->markTestSkipped('Requires openssl'); $this->markTestSkipped('Requires openssl');
} }
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'processUrl'); $method = new \ReflectionMethod($downloader, 'processUrl');
$method->setAccessible(true); $method->setAccessible(true);
$expected = 'https://github.com/composer/composer/zipball/master'; $expected = 'https://github.com/composer/composer/zipball/master';
$url = $method->invoke($downloader, $this->getMock('Composer\Package\PackageInterface'), $expected); $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected);
$this->assertEquals($expected, $url); $this->assertEquals($expected, $url);
} }
@ -55,12 +55,12 @@ class ArchiveDownloaderTest extends TestCase
$this->markTestSkipped('Requires openssl'); $this->markTestSkipped('Requires openssl');
} }
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'processUrl'); $method = new \ReflectionMethod($downloader, 'processUrl');
$method->setAccessible(true); $method->setAccessible(true);
$expected = 'https://github.com/composer/composer/archive/master.tar.gz'; $expected = 'https://github.com/composer/composer/archive/master.tar.gz';
$url = $method->invoke($downloader, $this->getMock('Composer\Package\PackageInterface'), $expected); $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected);
$this->assertEquals($expected, $url); $this->assertEquals($expected, $url);
} }
@ -71,12 +71,12 @@ class ArchiveDownloaderTest extends TestCase
$this->markTestSkipped('Requires openssl'); $this->markTestSkipped('Requires openssl');
} }
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'processUrl'); $method = new \ReflectionMethod($downloader, 'processUrl');
$method->setAccessible(true); $method->setAccessible(true);
$expected = 'https://api.github.com/repos/composer/composer/zipball/master'; $expected = 'https://api.github.com/repos/composer/composer/zipball/master';
$url = $method->invoke($downloader, $this->getMock('Composer\Package\PackageInterface'), $expected); $url = $method->invoke($downloader, $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(), $expected);
$this->assertEquals($expected, $url); $this->assertEquals($expected, $url);
} }
@ -90,14 +90,14 @@ class ArchiveDownloaderTest extends TestCase
$this->markTestSkipped('Requires openssl'); $this->markTestSkipped('Requires openssl');
} }
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'processUrl'); $method = new \ReflectionMethod($downloader, 'processUrl');
$method->setAccessible(true); $method->setAccessible(true);
$type = strpos($url, 'tar') ? 'tar' : 'zip'; $type = strpos($url, 'tar') ? 'tar' : 'zip';
$expected = 'https://api.github.com/repos/composer/composer/'.$type.'ball/ref'; $expected = 'https://api.github.com/repos/composer/composer/'.$type.'ball/ref';
$package = $this->getMock('Composer\Package\PackageInterface'); $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$package->expects($this->any()) $package->expects($this->any())
->method('getDistReference') ->method('getDistReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -127,14 +127,14 @@ class ArchiveDownloaderTest extends TestCase
$this->markTestSkipped('Requires openssl'); $this->markTestSkipped('Requires openssl');
} }
$downloader = $this->getMockForAbstractClass('Composer\Downloader\ArchiveDownloader', array($this->getMock('Composer\IO\IOInterface'), $this->getMock('Composer\Config'))); $downloader = $this->getArchiveDownloaderMock();
$method = new \ReflectionMethod($downloader, 'processUrl'); $method = new \ReflectionMethod($downloader, 'processUrl');
$method->setAccessible(true); $method->setAccessible(true);
$url = $url . '.' . $extension; $url = $url . '.' . $extension;
$expected = 'https://bitbucket.org/davereid/drush-virtualhost/get/ref.' . $extension; $expected = 'https://bitbucket.org/davereid/drush-virtualhost/get/ref.' . $extension;
$package = $this->getMock('Composer\Package\PackageInterface'); $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$package->expects($this->any()) $package->expects($this->any())
->method('getDistReference') ->method('getDistReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -151,4 +151,12 @@ class ArchiveDownloaderTest extends TestCase
array('https://bitbucket.org/davereid/drush-virtualhost/get/v1.0', 'tar.bz2'), array('https://bitbucket.org/davereid/drush-virtualhost/get/v1.0', 'tar.bz2'),
); );
} }
private function getArchiveDownloaderMock()
{
return $this->getMockForAbstractClass(
'Composer\Downloader\ArchiveDownloader',
array($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $this->getMockBuilder('Composer\Config')->getMock())
);
}
} }

View File

@ -22,8 +22,8 @@ class DownloadManagerTest extends TestCase
public function setUp() public function setUp()
{ {
$this->filesystem = $this->getMock('Composer\Util\Filesystem'); $this->filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
} }
public function testSetGetDownloader() public function testSetGetDownloader()

View File

@ -20,8 +20,8 @@ class FileDownloaderTest extends TestCase
{ {
protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $rfs = null, $filesystem = null) protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $rfs = null, $filesystem = null)
{ {
$io = $io ?: $this->getMock('Composer\IO\IOInterface'); $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $config ?: $this->getMock('Composer\Config'); $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock();
$rfs = $rfs ?: $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock(); $rfs = $rfs ?: $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock();
return new FileDownloader($io, $config, $eventDispatcher, $cache, $rfs, $filesystem); return new FileDownloader($io, $config, $eventDispatcher, $cache, $rfs, $filesystem);
@ -32,7 +32,7 @@ class FileDownloaderTest extends TestCase
*/ */
public function testDownloadForPackageWithoutDistReference() public function testDownloadForPackageWithoutDistReference()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue(null)) ->will($this->returnValue(null))
@ -44,7 +44,7 @@ class FileDownloaderTest extends TestCase
public function testDownloadToExistingFile() public function testDownloadToExistingFile()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue('url')) ->will($this->returnValue('url'))
@ -74,7 +74,7 @@ class FileDownloaderTest extends TestCase
public function testGetFileName() public function testGetFileName()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue('http://example.com/script.js')) ->will($this->returnValue('http://example.com/script.js'))
@ -89,7 +89,7 @@ class FileDownloaderTest extends TestCase
public function testDownloadButFileIsUnsaved() public function testDownloadButFileIsUnsaved()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue($distUrl = 'http://example.com/script.js')) ->will($this->returnValue($distUrl = 'http://example.com/script.js'))
@ -104,7 +104,7 @@ class FileDownloaderTest extends TestCase
; ;
$path = $this->getUniqueTmpDirectory(); $path = $this->getUniqueTmpDirectory();
$ioMock = $this->getMock('Composer\IO\IOInterface'); $ioMock = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$ioMock->expects($this->any()) $ioMock->expects($this->any())
->method('write') ->method('write')
->will($this->returnCallback(function ($messages, $newline = true) use ($path) { ->will($this->returnCallback(function ($messages, $newline = true) use ($path) {
@ -137,7 +137,7 @@ class FileDownloaderTest extends TestCase
{ {
$expectedTtl = '99999999'; $expectedTtl = '99999999';
$configMock = $this->getMock('Composer\Config'); $configMock = $this->getMockBuilder('Composer\Config')->getMock();
$configMock $configMock
->expects($this->at(0)) ->expects($this->at(0))
->method('get') ->method('get')
@ -166,7 +166,7 @@ class FileDownloaderTest extends TestCase
public function testDownloadFileWithInvalidChecksum() public function testDownloadFileWithInvalidChecksum()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue($distUrl = 'http://example.com/script.js')) ->will($this->returnValue($distUrl = 'http://example.com/script.js'))
@ -183,7 +183,7 @@ class FileDownloaderTest extends TestCase
->method('getDistUrls') ->method('getDistUrls')
->will($this->returnValue(array($distUrl))) ->will($this->returnValue(array($distUrl)))
; ;
$filesystem = $this->getMock('Composer\Util\Filesystem'); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$path = $this->getUniqueTmpDirectory(); $path = $this->getUniqueTmpDirectory();
$downloader = $this->getDownloader(null, null, null, null, null, $filesystem); $downloader = $this->getDownloader(null, null, null, null, null, $filesystem);

View File

@ -37,10 +37,10 @@ class FossilDownloaderTest 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->getMock('Composer\IO\IOInterface'); $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $config ?: $this->getMock('Composer\Config'); $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock();
$executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
return new FossilDownloader($io, $config, $executor, $filesystem); return new FossilDownloader($io, $config, $executor, $filesystem);
} }
@ -50,7 +50,7 @@ class FossilDownloaderTest extends TestCase
*/ */
public function testDownloadForPackageWithoutSourceReference() public function testDownloadForPackageWithoutSourceReference()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -61,14 +61,14 @@ class FossilDownloaderTest extends TestCase
public function testDownload() public function testDownload()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('trunk')); ->will($this->returnValue('trunk'));
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('http://fossil.kd2.org/kd2fw/'))); ->will($this->returnValue(array('http://fossil.kd2.org/kd2fw/')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedFossilCommand = $this->getCmd('fossil clone \'http://fossil.kd2.org/kd2fw/\' \'repo.fossil\''); $expectedFossilCommand = $this->getCmd('fossil clone \'http://fossil.kd2.org/kd2fw/\' \'repo.fossil\'');
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -97,8 +97,8 @@ class FossilDownloaderTest extends TestCase
*/ */
public function testUpdateforPackageWithoutSourceReference() public function testUpdateforPackageWithoutSourceReference()
{ {
$initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock->expects($this->once()) $sourcePackageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -116,14 +116,14 @@ class FossilDownloaderTest extends TestCase
touch($file); touch($file);
} }
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('trunk')); ->will($this->returnValue('trunk'));
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('http://fossil.kd2.org/kd2fw/'))); ->will($this->returnValue(array('http://fossil.kd2.org/kd2fw/')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedFossilCommand = $this->getCmd("fossil changes"); $expectedFossilCommand = $this->getCmd("fossil changes");
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -144,12 +144,12 @@ class FossilDownloaderTest extends TestCase
{ {
$expectedResetCommand = $this->getCmd('cd \'composerPath\' && fossil status'); $expectedResetCommand = $this->getCmd('cd \'composerPath\' && fossil status');
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->any()) $processExecutor->expects($this->any())
->method('execute') ->method('execute')
->with($this->equalTo($expectedResetCommand)); ->with($this->equalTo($expectedResetCommand));
$filesystem = $this->getMock('Composer\Util\Filesystem'); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->any())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))

View File

@ -60,9 +60,9 @@ 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->getMock('Composer\IO\IOInterface'); $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$config = $this->setupConfig($config); $config = $this->setupConfig($config);
return new GitDownloader($io, $config, $executor, $filesystem); return new GitDownloader($io, $config, $executor, $filesystem);
@ -73,7 +73,7 @@ class GitDownloaderTest extends TestCase
*/ */
public function testDownloadForPackageWithoutSourceReference() public function testDownloadForPackageWithoutSourceReference()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -84,7 +84,7 @@ class GitDownloaderTest extends TestCase
public function testDownload() public function testDownload()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('1234567890123456789012345678901234567890')); ->will($this->returnValue('1234567890123456789012345678901234567890'));
@ -97,7 +97,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
@ -135,7 +135,7 @@ class GitDownloaderTest extends TestCase
public function testDownloadWithCache() public function testDownloadWithCache()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('1234567890123456789012345678901234567890')); ->will($this->returnValue('1234567890123456789012345678901234567890'));
@ -148,7 +148,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
@ -201,7 +201,7 @@ class GitDownloaderTest extends TestCase
public function testDownloadUsesVariousProtocolsAndSetsPushUrlForGithub() public function testDownloadUsesVariousProtocolsAndSetsPushUrlForGithub()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -214,7 +214,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
@ -285,7 +285,7 @@ class GitDownloaderTest extends TestCase
*/ */
public function testDownloadAndSetPushUrlUseCustomVariousProtocolsForGithub($protocols, $url, $pushUrl) public function testDownloadAndSetPushUrlUseCustomVariousProtocolsForGithub($protocols, $url, $pushUrl)
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -298,7 +298,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
@ -338,14 +338,14 @@ class GitDownloaderTest extends TestCase
public function testDownloadThrowsRuntimeExceptionIfGitCommandFails() public function testDownloadThrowsRuntimeExceptionIfGitCommandFails()
{ {
$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"); $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");
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->with($this->equalTo($this->winCompat('git --version')))
@ -368,8 +368,8 @@ class GitDownloaderTest extends TestCase
*/ */
public function testUpdateforPackageWithoutSourceReference() public function testUpdateforPackageWithoutSourceReference()
{ {
$initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock->expects($this->once()) $sourcePackageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -382,7 +382,7 @@ class GitDownloaderTest extends TestCase
{ {
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)"); $expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)");
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -392,7 +392,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->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")))
@ -431,7 +431,7 @@ class GitDownloaderTest extends TestCase
{ {
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)"); $expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)");
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
@ -444,7 +444,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->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->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")))
@ -503,14 +503,14 @@ composer https://github.com/old/url (push)
{ {
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)"); $expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)");
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('https://github.com/composer/composer'))); ->will($this->returnValue(array('https://github.com/composer/composer')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->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")))
@ -542,14 +542,14 @@ composer https://github.com/old/url (push)
$expectedFirstGitUpdateCommand = $this->winCompat("git remote set-url composer '' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)"); $expectedFirstGitUpdateCommand = $this->winCompat("git remote set-url composer '' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)");
$expectedSecondGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)"); $expectedSecondGitUpdateCommand = $this->winCompat("git remote set-url composer 'https://github.com/composer/composer' && git rev-parse --quiet --verify 'ref^{commit}' || (git fetch composer && git fetch --tags composer)");
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('/foo/bar', 'https://github.com/composer/composer'))); ->will($this->returnValue(array('/foo/bar', 'https://github.com/composer/composer')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->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")))
@ -600,13 +600,13 @@ 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->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->any()) $processExecutor->expects($this->any())
->method('execute') ->method('execute')
->with($this->equalTo($expectedGitResetCommand)) ->with($this->equalTo($expectedGitResetCommand))
->will($this->returnValue(0)); ->will($this->returnValue(0));
$filesystem = $this->getMock('Composer\Util\Filesystem'); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->any())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))

View File

@ -37,10 +37,10 @@ class HgDownloaderTest 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->getMock('Composer\IO\IOInterface'); $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $config ?: $this->getMock('Composer\Config'); $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock();
$executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
return new HgDownloader($io, $config, $executor, $filesystem); return new HgDownloader($io, $config, $executor, $filesystem);
} }
@ -50,7 +50,7 @@ class HgDownloaderTest extends TestCase
*/ */
public function testDownloadForPackageWithoutSourceReference() public function testDownloadForPackageWithoutSourceReference()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -61,14 +61,14 @@ class HgDownloaderTest extends TestCase
public function testDownload() public function testDownload()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$packageMock->expects($this->once()) $packageMock->expects($this->once())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('https://mercurial.dev/l3l0/composer'))); ->will($this->returnValue(array('https://mercurial.dev/l3l0/composer')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedGitCommand = $this->getCmd('hg clone \'https://mercurial.dev/l3l0/composer\' \'composerPath\''); $expectedGitCommand = $this->getCmd('hg clone \'https://mercurial.dev/l3l0/composer\' \'composerPath\'');
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -91,8 +91,8 @@ class HgDownloaderTest extends TestCase
*/ */
public function testUpdateforPackageWithoutSourceReference() public function testUpdateforPackageWithoutSourceReference()
{ {
$initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$sourcePackageMock->expects($this->once()) $sourcePackageMock->expects($this->once())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue(null)); ->will($this->returnValue(null));
@ -105,14 +105,14 @@ class HgDownloaderTest extends TestCase
{ {
$fs = new Filesystem; $fs = new Filesystem;
$fs->ensureDirectoryExists($this->workingDir.'/.hg'); $fs->ensureDirectoryExists($this->workingDir.'/.hg');
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue('ref')); ->will($this->returnValue('ref'));
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getSourceUrls') ->method('getSourceUrls')
->will($this->returnValue(array('https://github.com/l3l0/composer'))); ->will($this->returnValue(array('https://github.com/l3l0/composer')));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedHgCommand = $this->getCmd("hg st"); $expectedHgCommand = $this->getCmd("hg st");
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -133,12 +133,12 @@ class HgDownloaderTest extends TestCase
{ {
$expectedResetCommand = $this->getCmd('cd \'composerPath\' && hg st'); $expectedResetCommand = $this->getCmd('cd \'composerPath\' && hg st');
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->any()) $processExecutor->expects($this->any())
->method('execute') ->method('execute')
->with($this->equalTo($expectedResetCommand)); ->with($this->equalTo($expectedResetCommand));
$filesystem = $this->getMock('Composer\Util\Filesystem'); $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$filesystem->expects($this->any()) $filesystem->expects($this->any())
->method('removeDirectory') ->method('removeDirectory')
->with($this->equalTo('composerPath')) ->with($this->equalTo('composerPath'))

View File

@ -62,7 +62,7 @@ class PerforceDownloaderTest extends TestCase
protected function getMockProcessExecutor() protected function getMockProcessExecutor()
{ {
return $this->getMock('Composer\Util\ProcessExecutor'); return $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
} }
protected function getConfig() protected function getConfig()
@ -76,12 +76,12 @@ class PerforceDownloaderTest extends TestCase
protected function getMockIoInterface() protected function getMockIoInterface()
{ {
return $this->getMock('Composer\IO\IOInterface'); return $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
} }
protected function getMockPackageInterface(VcsRepository $repository) protected function getMockPackageInterface(VcsRepository $repository)
{ {
$package = $this->getMock('Composer\Package\PackageInterface'); $package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$package->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $package->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
return $package; return $package;
@ -94,10 +94,10 @@ class PerforceDownloaderTest extends TestCase
protected function getMockRepository(array $repoConfig, IOInterface $io, Config $config) protected function getMockRepository(array $repoConfig, IOInterface $io, Config $config)
{ {
$class = 'Composer\Repository\VcsRepository'; $repository = $this->getMockBuilder('Composer\Repository\VcsRepository')
$methods = array('getRepoConfig'); ->setMethods(array('getRepoConfig'))
$args = array($repoConfig, $io, $config); ->setConstructorArgs(array($repoConfig, $io, $config))
$repository = $this->getMock($class, $methods, $args); ->getMock();
$repository->expects($this->any())->method('getRepoConfig')->will($this->returnValue($repoConfig)); $repository->expects($this->any())->method('getRepoConfig')->will($this->returnValue($repoConfig));
return $repository; return $repository;

View File

@ -46,7 +46,7 @@ class XzDownloaderTest extends TestCase
public function testErrorMessages() public function testErrorMessages()
{ {
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue($distUrl = 'file://'.__FILE__)) ->will($this->returnValue($distUrl = 'file://'.__FILE__))
@ -60,8 +60,8 @@ class XzDownloaderTest extends TestCase
->will($this->returnValue(array())) ->will($this->returnValue(array()))
; ;
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $this->getMock('Composer\Config'); $config = $this->getMockBuilder('Composer\Config')->getMock();
$config->expects($this->any()) $config->expects($this->any())
->method('get') ->method('get')
->with('vendor-dir') ->with('vendor-dir')

View File

@ -28,8 +28,8 @@ class ZipDownloaderTest extends TestCase
public function setUp() public function setUp()
{ {
$this->testDir = $this->getUniqueTmpDirectory(); $this->testDir = $this->getUniqueTmpDirectory();
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->config = $this->getMock('Composer\Config'); $this->config = $this->getMockBuilder('Composer\Config')->getMock();
} }
public function tearDown() public function tearDown()
@ -78,7 +78,7 @@ class ZipDownloaderTest extends TestCase
->with('vendor-dir') ->with('vendor-dir')
->will($this->returnValue($this->testDir)); ->will($this->returnValue($this->testDir));
$packageMock = $this->getMock('Composer\Package\PackageInterface'); $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$packageMock->expects($this->any()) $packageMock->expects($this->any())
->method('getDistUrl') ->method('getDistUrl')
->will($this->returnValue($distUrl = 'file://'.__FILE__)) ->will($this->returnValue($distUrl = 'file://'.__FILE__))
@ -118,7 +118,7 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$downloader = new MockedZipDownloader($this->io, $this->config); $downloader = new MockedZipDownloader($this->io, $this->config);
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -144,7 +144,7 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$downloader = new MockedZipDownloader($this->io, $this->config); $downloader = new MockedZipDownloader($this->io, $this->config);
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -169,7 +169,7 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$downloader = new MockedZipDownloader($this->io, $this->config); $downloader = new MockedZipDownloader($this->io, $this->config);
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -193,7 +193,7 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', false); $this->setPrivateProperty('hasZipArchive', false);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
@ -210,7 +210,7 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', false); $this->setPrivateProperty('hasZipArchive', false);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->will($this->returnValue(0)); ->will($this->returnValue(0));
@ -229,12 +229,12 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -261,12 +261,12 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -289,12 +289,12 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->atLeastOnce()) $processExecutor->expects($this->atLeastOnce())
->method('execute') ->method('execute')
->will($this->returnValue(0)); ->will($this->returnValue(0));
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -321,12 +321,12 @@ class ZipDownloaderTest extends TestCase
$this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasSystemUnzip', true);
$this->setPrivateProperty('hasZipArchive', true); $this->setPrivateProperty('hasZipArchive', true);
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$processExecutor->expects($this->atLeastOnce()) $processExecutor->expects($this->atLeastOnce())
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
$zipArchive = $this->getMock('ZipArchive'); $zipArchive = $this->getMockBuilder('ZipArchive')->getMock();
$zipArchive->expects($this->at(0)) $zipArchive->expects($this->at(0))
->method('open') ->method('open')
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -31,7 +31,7 @@ class EventDispatcherTest extends TestCase
*/ */
public function testListenerExceptionsAreCaught() public function testListenerExceptionsAreCaught()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$dispatcher = $this->getDispatcherStubForListenersTest(array( $dispatcher = $this->getDispatcherStubForListenersTest(array(
'Composer\Test\EventDispatcher\EventDispatcherTest::call', 'Composer\Test\EventDispatcher\EventDispatcherTest::call',
), $io); ), $io);
@ -56,7 +56,7 @@ class EventDispatcherTest extends TestCase
*/ */
public function testDispatcherCanConvertScriptEventToCommandEventForListener() public function testDispatcherCanConvertScriptEventToCommandEventForListener()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$dispatcher = $this->getDispatcherStubForListenersTest(array( $dispatcher = $this->getDispatcherStubForListenersTest(array(
'Composer\Test\EventDispatcher\EventDispatcherTest::expectsCommandEvent', 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsCommandEvent',
), $io); ), $io);
@ -66,7 +66,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherDoesNotAttemptConversionForListenerWithoutTypehint() public function testDispatcherDoesNotAttemptConversionForListenerWithoutTypehint()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$dispatcher = $this->getDispatcherStubForListenersTest(array( $dispatcher = $this->getDispatcherStubForListenersTest(array(
'Composer\Test\EventDispatcher\EventDispatcherTest::expectsVariableEvent', 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsVariableEvent',
), $io); ), $io);
@ -80,11 +80,11 @@ class EventDispatcherTest extends TestCase
*/ */
public function testDispatcherCanExecuteSingleCommandLineScript($command) public function testDispatcherCanExecuteSingleCommandLineScript($command)
{ {
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->createComposerInstance(), $this->createComposerInstance(),
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$process, $process,
)) ))
->setMethods(array('getListeners')) ->setMethods(array('getListeners'))
@ -118,17 +118,17 @@ class EventDispatcherTest extends TestCase
$composer->setAutoloadGenerator($generator); $composer->setAutoloadGenerator($generator);
$package = $this->getMock('Composer\Package\RootPackageInterface'); $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$package->method('getScripts')->will($this->returnValue(array('scriptName' => array('scriptName')))); $package->method('getScripts')->will($this->returnValue(array('scriptName' => array('scriptName'))));
$composer->setPackage($package); $composer->setPackage($package);
$composer->setRepositoryManager($this->getRepositoryManagerMockForDevModePassingTest()); $composer->setRepositoryManager($this->getRepositoryManagerMockForDevModePassingTest());
$composer->setInstallationManager($this->getMock('Composer\Installer\InstallationManager')); $composer->setInstallationManager($this->getMockBuilder('Composer\Installer\InstallationManager')->getMock());
$dispatcher = new EventDispatcher( $dispatcher = new EventDispatcher(
$composer, $composer,
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$this->getMock('Composer\Util\ProcessExecutor') $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock()
); );
$event = $this->getMockBuilder('Composer\Script\Event') $event = $this->getMockBuilder('Composer\Script\Event')
@ -169,7 +169,7 @@ class EventDispatcherTest extends TestCase
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$generator $generator
->method('createLoader') ->method('createLoader')
->will($this->returnValue($this->getMock('Composer\Autoload\ClassLoader'))); ->will($this->returnValue($this->getMockBuilder('Composer\Autoload\ClassLoader')->getMock()));
return $generator; return $generator;
} }
@ -181,7 +181,7 @@ class EventDispatcherTest extends TestCase
->setMethods(array('getLocalRepository')) ->setMethods(array('getLocalRepository'))
->getMock(); ->getMock();
$repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $repo = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
$repo $repo
->method('getCanonicalPackages') ->method('getCanonicalPackages')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -195,7 +195,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack() public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack()
{ {
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->createComposerInstance(), $this->createComposerInstance(),
@ -231,7 +231,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherCanExecuteComposerScriptGroups() public function testDispatcherCanExecuteComposerScriptGroups()
{ {
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$composer = $this->createComposerInstance(), $composer = $this->createComposerInstance(),
@ -279,11 +279,11 @@ class EventDispatcherTest extends TestCase
*/ */
public function testDispatcherDetectInfiniteRecursion() public function testDispatcherDetectInfiniteRecursion()
{ {
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$composer = $this->createComposerInstance(), $composer = $this->createComposerInstance(),
$io = $this->getMock('Composer\IO\IOInterface'), $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$process, $process,
)) ))
->setMethods(array( ->setMethods(array(
@ -339,7 +339,7 @@ class EventDispatcherTest extends TestCase
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->createComposerInstance(), $this->createComposerInstance(),
$io = $this->getMock('Composer\IO\IOInterface'), $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
new ProcessExecutor($io), new ProcessExecutor($io),
)) ))
->setMethods(array('getListeners')) ->setMethods(array('getListeners'))
@ -366,7 +366,7 @@ class EventDispatcherTest extends TestCase
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->createComposerInstance(), $this->createComposerInstance(),
$io = $this->getMock('Composer\IO\IOInterface'), $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
new ProcessExecutor, new ProcessExecutor,
)) ))
->setMethods(array('getListeners')) ->setMethods(array('getListeners'))
@ -396,11 +396,11 @@ class EventDispatcherTest extends TestCase
public function testDispatcherInstallerEvents() public function testDispatcherInstallerEvents()
{ {
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array( ->setConstructorArgs(array(
$this->createComposerInstance(), $this->createComposerInstance(),
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$process, $process,
)) ))
->setMethods(array('getListeners')) ->setMethods(array('getListeners'))
@ -410,7 +410,7 @@ class EventDispatcherTest extends TestCase
->method('getListeners') ->method('getListeners')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$policy = $this->getMock('Composer\DependencyResolver\PolicyInterface'); $policy = $this->getMockBuilder('Composer\DependencyResolver\PolicyInterface')->getMock();
$pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock(); $pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock();
$installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock(); $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
$request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
@ -444,7 +444,7 @@ class EventDispatcherTest extends TestCase
$composer = new Composer; $composer = new Composer;
$config = new Config; $config = new Config;
$composer->setConfig($config); $composer->setConfig($config);
$package = $this->getMock('Composer\Package\RootPackageInterface'); $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$composer->setPackage($package); $composer->setPackage($package);
return $composer; return $composer;

View File

@ -20,7 +20,7 @@ class ConsoleIOTest extends TestCase
{ {
public function testIsInteractive() public function testIsInteractive()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$inputMock->expects($this->at(0)) $inputMock->expects($this->at(0))
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -28,8 +28,8 @@ class ConsoleIOTest extends TestCase
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(false)); ->will($this->returnValue(false));
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
@ -39,15 +39,15 @@ class ConsoleIOTest extends TestCase
public function testWrite() public function testWrite()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$outputMock->expects($this->once()) $outputMock->expects($this->once())
->method('getVerbosity') ->method('getVerbosity')
->willReturn(OutputInterface::VERBOSITY_NORMAL); ->willReturn(OutputInterface::VERBOSITY_NORMAL);
$outputMock->expects($this->once()) $outputMock->expects($this->once())
->method('write') ->method('write')
->with($this->equalTo('some information about something'), $this->equalTo(false)); ->with($this->equalTo('some information about something'), $this->equalTo(false));
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->write('some information about something', false); $consoleIO->write('some information about something', false);
@ -55,8 +55,8 @@ class ConsoleIOTest extends TestCase
public function testWriteError() public function testWriteError()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\ConsoleOutputInterface')->getMock();
$outputMock->expects($this->once()) $outputMock->expects($this->once())
->method('getVerbosity') ->method('getVerbosity')
->willReturn(OutputInterface::VERBOSITY_NORMAL); ->willReturn(OutputInterface::VERBOSITY_NORMAL);
@ -66,7 +66,7 @@ class ConsoleIOTest extends TestCase
$outputMock->expects($this->once()) $outputMock->expects($this->once())
->method('write') ->method('write')
->with($this->equalTo('some information about something'), $this->equalTo(false)); ->with($this->equalTo('some information about something'), $this->equalTo(false));
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->writeError('some information about something', false); $consoleIO->writeError('some information about something', false);
@ -74,8 +74,8 @@ class ConsoleIOTest extends TestCase
public function testWriteWithMultipleLineStringWhenDebugging() public function testWriteWithMultipleLineStringWhenDebugging()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$outputMock->expects($this->once()) $outputMock->expects($this->once())
->method('getVerbosity') ->method('getVerbosity')
->willReturn(OutputInterface::VERBOSITY_NORMAL); ->willReturn(OutputInterface::VERBOSITY_NORMAL);
@ -90,7 +90,7 @@ class ConsoleIOTest extends TestCase
}), }),
$this->equalTo(false) $this->equalTo(false)
); );
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$startTime = microtime(true); $startTime = microtime(true);
@ -102,8 +102,8 @@ class ConsoleIOTest extends TestCase
public function testOverwrite() public function testOverwrite()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$outputMock->expects($this->any()) $outputMock->expects($this->any())
->method('getVerbosity') ->method('getVerbosity')
@ -130,7 +130,7 @@ class ConsoleIOTest extends TestCase
->method('write') ->method('write')
->with($this->equalTo('something longer than initial (<info>34</info>)')); ->with($this->equalTo('something longer than initial (<info>34</info>)'));
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->write('something (<question>strlen = 23</question>)'); $consoleIO->write('something (<question>strlen = 23</question>)');
@ -140,10 +140,10 @@ class ConsoleIOTest extends TestCase
public function testAsk() public function testAsk()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock();
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$helperMock $helperMock
->expects($this->once()) ->expects($this->once())
@ -168,10 +168,10 @@ class ConsoleIOTest extends TestCase
public function testAskConfirmation() public function testAskConfirmation()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock();
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$helperMock $helperMock
->expects($this->once()) ->expects($this->once())
@ -196,10 +196,10 @@ class ConsoleIOTest extends TestCase
public function testAskAndValidate() public function testAskAndValidate()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock();
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$helperMock $helperMock
->expects($this->once()) ->expects($this->once())
@ -227,10 +227,10 @@ class ConsoleIOTest extends TestCase
public function testSelect() public function testSelect()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock();
$setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$helperMock $helperMock
->expects($this->once()) ->expects($this->once())
@ -257,9 +257,9 @@ class ConsoleIOTest extends TestCase
public function testSetAndgetAuthentication() public function testSetAndgetAuthentication()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');
@ -272,9 +272,9 @@ class ConsoleIOTest extends TestCase
public function testGetAuthenticationWhenDidNotSet() public function testGetAuthenticationWhenDidNotSet()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
@ -286,9 +286,9 @@ class ConsoleIOTest extends TestCase
public function testHasAuthentication() public function testHasAuthentication()
{ {
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock();
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
$consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd');

View File

@ -22,7 +22,7 @@ class InstallationManagerTest extends TestCase
{ {
public function setUp() public function setUp()
{ {
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
} }
public function testAddGetInstaller() public function testAddGetInstaller()

View File

@ -19,13 +19,13 @@ class InstallerEventTest extends TestCase
{ {
public function testGetter() public function testGetter()
{ {
$composer = $this->getMock('Composer\Composer'); $composer = $this->getMockBuilder('Composer\Composer')->getMock();
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$policy = $this->getMock('Composer\DependencyResolver\PolicyInterface'); $policy = $this->getMockBuilder('Composer\DependencyResolver\PolicyInterface')->getMock();
$pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock(); $pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock();
$installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock(); $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
$request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
$operations = array($this->getMock('Composer\DependencyResolver\Operation\OperationInterface')); $operations = array($this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock());
$event = new InstallerEvent('EVENT_NAME', $composer, $io, true, $policy, $pool, $installedRepo, $request, $operations); $event = new InstallerEvent('EVENT_NAME', $composer, $io, true, $policy, $pool, $installedRepo, $request, $operations);
$this->assertSame('EVENT_NAME', $event->getName()); $this->assertSame('EVENT_NAME', $event->getName());

View File

@ -57,8 +57,8 @@ class LibraryInstallerTest extends TestCase
->getMock(); ->getMock();
$this->composer->setDownloadManager($this->dm); $this->composer->setDownloadManager($this->dm);
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
} }
protected function tearDown() protected function tearDown()

View File

@ -23,9 +23,9 @@ class MetapackageInstallerTest extends TestCase
protected function setUp() protected function setUp()
{ {
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->installer = new MetapackageInstaller(); $this->installer = new MetapackageInstaller();
} }

View File

@ -25,7 +25,7 @@ class SuggestedPackagesReporterTest extends TestCase
protected function setUp() protected function setUp()
{ {
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io); $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
} }
@ -185,9 +185,9 @@ class SuggestedPackagesReporterTest extends TestCase
*/ */
public function testOutputSkipInstalledPackages() public function testOutputSkipInstalledPackages()
{ {
$repository = $this->getMock('Composer\Repository\RepositoryInterface'); $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock();
$package1 = $this->getMock('Composer\Package\PackageInterface'); $package1 = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$package2 = $this->getMock('Composer\Package\PackageInterface'); $package2 = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
$package1->expects($this->once()) $package1->expects($this->once())
->method('getNames') ->method('getNames')
@ -219,7 +219,7 @@ class SuggestedPackagesReporterTest extends TestCase
*/ */
public function testOutputNotGettingInstalledPackagesWhenNoSuggestions() public function testOutputNotGettingInstalledPackagesWhenNoSuggestions()
{ {
$repository = $this->getMock('Composer\Repository\RepositoryInterface'); $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock();
$repository->expects($this->exactly(0)) $repository->expects($this->exactly(0))
->method('getPackages'); ->method('getPackages');

View File

@ -57,10 +57,12 @@ class InstallerTest extends TestCase
*/ */
public function testInstaller(RootPackageInterface $rootPackage, $repositories, array $options) public function testInstaller(RootPackageInterface $rootPackage, $repositories, array $options)
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$downloadManager = $this->getMock('Composer\Downloader\DownloadManager', array(), array($io)); $downloadManager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
$config = $this->getMock('Composer\Config'); ->setConstructorArgs(array($io))
->getMock();
$config = $this->getMockBuilder('Composer\Config')->getMock();
$repositoryManager = new RepositoryManager($io, $config); $repositoryManager = new RepositoryManager($io, $config);
$repositoryManager->setLocalRepository(new InstalledArrayRepository()); $repositoryManager->setLocalRepository(new InstalledArrayRepository());
@ -202,7 +204,9 @@ class InstallerTest extends TestCase
$composer->setLocker($locker); $composer->setLocker($locker);
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); $eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$autoloadGenerator = $this->getMock('Composer\Autoload\AutoloadGenerator', array(), array($eventDispatcher)); $autoloadGenerator = $this->getMockBuilder('Composer\Autoload\AutoloadGenerator')
->setConstructorArgs(array($eventDispatcher))
->getMock();
$composer->setAutoloadGenerator($autoloadGenerator); $composer->setAutoloadGenerator($autoloadGenerator);
$composer->setEventDispatcher($eventDispatcher); $composer->setEventDispatcher($eventDispatcher);

View File

@ -20,7 +20,7 @@ class BasePackageTest extends TestCase
public function testSetSameRepository() public function testSetSameRepository()
{ {
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo')); $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
$repository = $this->getMock('Composer\Repository\RepositoryInterface'); $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock();
$package->setRepository($repository); $package->setRepository($repository);
try { try {
@ -37,8 +37,8 @@ class BasePackageTest extends TestCase
{ {
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo')); $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface')); $package->setRepository($this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock());
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface')); $package->setRepository($this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock());
} }
/** /**

View File

@ -31,7 +31,7 @@ class ArrayDumperTest extends TestCase
public function setUp() public function setUp()
{ {
$this->dumper = new ArrayDumper(); $this->dumper = new ArrayDumper();
$this->package = $this->getMock('Composer\Package\CompletePackageInterface'); $this->package = $this->getMockBuilder('Composer\Package\CompletePackageInterface')->getMock();
$this->packageExpects('getTransportOptions', array()); $this->packageExpects('getTransportOptions', array());
} }
@ -56,7 +56,7 @@ class ArrayDumperTest extends TestCase
public function testRootPackage() public function testRootPackage()
{ {
$this->package = $this->getMock('Composer\Package\RootPackageInterface'); $this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$this $this
->packageExpects('getMinimumStability', 'dev') ->packageExpects('getMinimumStability', 'dev')
@ -92,7 +92,7 @@ class ArrayDumperTest extends TestCase
*/ */
public function testKeys($key, $value, $method = null, $expectedValue = null) public function testKeys($key, $value, $method = null, $expectedValue = null)
{ {
$this->package = $this->getMock('Composer\Package\RootPackageInterface'); $this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$this->packageExpects('get'.ucfirst($method ?: $key), $value); $this->packageExpects('get'.ucfirst($method ?: $key), $value);
$this->packageExpects('isAbandoned', $value); $this->packageExpects('isAbandoned', $value);

View File

@ -23,7 +23,7 @@ class ValidatingArrayLoaderTest extends TestCase
*/ */
public function testLoadSuccess($config) public function testLoadSuccess($config)
{ {
$internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock();
$internalLoader $internalLoader
->expects($this->once()) ->expects($this->once())
->method('load') ->method('load')
@ -171,7 +171,7 @@ class ValidatingArrayLoaderTest extends TestCase
*/ */
public function testLoadFailureThrowsException($config, $expectedErrors) public function testLoadFailureThrowsException($config, $expectedErrors)
{ {
$internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock();
$loader = new ValidatingArrayLoader($internalLoader, true, null, ValidatingArrayLoader::CHECK_ALL); $loader = new ValidatingArrayLoader($internalLoader, true, null, ValidatingArrayLoader::CHECK_ALL);
try { try {
$loader->load($config); $loader->load($config);
@ -189,7 +189,7 @@ class ValidatingArrayLoaderTest extends TestCase
*/ */
public function testLoadWarnings($config, $expectedWarnings) public function testLoadWarnings($config, $expectedWarnings)
{ {
$internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock();
$loader = new ValidatingArrayLoader($internalLoader, true, null, ValidatingArrayLoader::CHECK_ALL); $loader = new ValidatingArrayLoader($internalLoader, true, null, ValidatingArrayLoader::CHECK_ALL);
$loader->load($config); $loader->load($config);
@ -209,7 +209,7 @@ class ValidatingArrayLoaderTest extends TestCase
return; return;
} }
$internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock();
$internalLoader $internalLoader
->expects($this->once()) ->expects($this->once())
->method('load') ->method('load')

View File

@ -198,7 +198,7 @@ class VersionSelectorTest extends TestCase
$versionSelector = new VersionSelector($pool); $versionSelector = new VersionSelector($pool);
$versionParser = new VersionParser(); $versionParser = new VersionParser();
$package = $this->getMock('\Composer\Package\PackageInterface'); $package = $this->getMockBuilder('\Composer\Package\PackageInterface')->getMock();
$package $package
->expects($this->any()) ->expects($this->any())
->method('getPrettyVersion') ->method('getPrettyVersion')
@ -275,6 +275,6 @@ class VersionSelectorTest extends TestCase
private function createMockPool() private function createMockPool()
{ {
return $this->getMock('Composer\DependencyResolver\Pool', array(), array(), '', true); return $this->getMockBuilder('Composer\DependencyResolver\Pool')->getMock();
} }
} }

View File

@ -80,7 +80,7 @@ class PluginInstallerTest extends TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
$rm = $this->getMockBuilder('Composer\Repository\RepositoryManager') $rm = $this->getMockBuilder('Composer\Repository\RepositoryManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -89,14 +89,14 @@ class PluginInstallerTest extends TestCase
->method('getLocalRepository') ->method('getLocalRepository')
->will($this->returnValue($this->repository)); ->will($this->returnValue($this->repository));
$im = $this->getMock('Composer\Installer\InstallationManager'); $im = $this->getMockBuilder('Composer\Installer\InstallationManager')->getMock();
$im->expects($this->any()) $im->expects($this->any())
->method('getInstallPath') ->method('getInstallPath')
->will($this->returnCallback(function ($package) { ->will($this->returnCallback(function ($package) {
return __DIR__.'/Fixtures/'.$package->getPrettyName(); return __DIR__.'/Fixtures/'.$package->getPrettyName();
})); }));
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->autoloadGenerator = new AutoloadGenerator($dispatcher); $this->autoloadGenerator = new AutoloadGenerator($dispatcher);

View File

@ -31,18 +31,14 @@ class ComposerRepositoryTest extends TestCase
'url' => 'http://example.org', 'url' => 'http://example.org',
); );
$repository = $this->getMock( $repository = $this->getMockBuilder('Composer\Repository\ComposerRepository')
'Composer\Repository\ComposerRepository', ->setMethods(array('loadRootServerFile', 'createPackage'))
array( ->setConstructorArgs(array(
'loadRootServerFile',
'createPackage',
),
array(
$repoConfig, $repoConfig,
new NullIO, new NullIO,
FactoryMock::createConfig(), FactoryMock::createConfig(),
) ))
); ->getMock();
$repository $repository
->expects($this->exactly(2)) ->expects($this->exactly(2))
@ -146,7 +142,7 @@ class ComposerRepositoryTest extends TestCase
), ),
))); )));
$pool = $this->getMock('Composer\DependencyResolver\Pool'); $pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->getMock();
$pool->expects($this->any()) $pool->expects($this->any())
->method('isPackageAcceptable') ->method('isPackageAcceptable')
->will($this->returnValue(true)); ->will($this->returnValue(true));

View File

@ -20,8 +20,8 @@ class RepositoryFactoryTest extends TestCase
public function testManagerWithAllRepositoryTypes() public function testManagerWithAllRepositoryTypes()
{ {
$manager = RepositoryFactory::manager( $manager = RepositoryFactory::manager(
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$this->getMock('Composer\Config') $this->getMockBuilder('Composer\Config')->getMock()
); );
$ref = new \ReflectionProperty($manager, 'repositoryClasses'); $ref = new \ReflectionProperty($manager, 'repositoryClasses');

View File

@ -36,13 +36,13 @@ class RepositoryManagerTest extends TestCase
public function testPrepend() public function testPrepend()
{ {
$rm = new RepositoryManager( $rm = new RepositoryManager(
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$this->getMock('Composer\Config'), $this->getMockBuilder('Composer\Config')->getMock(),
$this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock()
); );
$repository1 = $this->getMock('Composer\Repository\RepositoryInterface'); $repository1 = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock();
$repository2 = $this->getMock('Composer\Repository\RepositoryInterface'); $repository2 = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock();
$rm->addRepository($repository1); $rm->addRepository($repository1);
$rm->prependRepository($repository2); $rm->prependRepository($repository2);
@ -59,8 +59,8 @@ class RepositoryManagerTest extends TestCase
} }
$rm = new RepositoryManager( $rm = new RepositoryManager(
$this->getMock('Composer\IO\IOInterface'), $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
$config = $this->getMock('Composer\Config', array('get')), $config = $this->getMockBuilder('Composer\Config')->setMethods(array('get'))->getMock(),
$this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock()
); );

View File

@ -64,7 +64,7 @@ class FossilDriverTest extends TestCase
public function testSupport($url, $assertion) public function testSupport($url, $assertion)
{ {
$config = new Config(); $config = new Config();
$result = FossilDriver::supports($this->getMock('Composer\IO\IOInterface'), $config, $url); $result = FossilDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url);
$this->assertEquals($assertion, $result); $this->assertEquals($assertion, $result);
} }
} }

View File

@ -35,7 +35,7 @@ class GitBitbucketDriverTest extends TestCase
protected function setUp() protected function setUp()
{ {
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->home = $this->getUniqueTmpDirectory(); $this->home = $this->getUniqueTmpDirectory();

View File

@ -48,7 +48,7 @@ class GitHubDriverTest extends TestCase
$identifier = 'v0.0.0'; $identifier = 'v0.0.0';
$sha = 'SOMESHA'; $sha = 'SOMESHA';
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->any()) $io->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -57,7 +57,7 @@ class GitHubDriverTest extends TestCase
->setConstructorArgs(array($io)) ->setConstructorArgs(array($io))
->getMock(); ->getMock();
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$process->expects($this->any()) $process->expects($this->any())
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
@ -86,8 +86,8 @@ class GitHubDriverTest extends TestCase
->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false)) ->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false))
->will($this->returnValue('{"master_branch": "test_master", "private": true, "owner": {"login": "composer"}, "name": "packagist"}')); ->will($this->returnValue('{"master_branch": "test_master", "private": true, "owner": {"login": "composer"}, "name": "packagist"}'));
$configSource = $this->getMock('Composer\Config\ConfigSourceInterface'); $configSource = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock();
$authConfigSource = $this->getMock('Composer\Config\ConfigSourceInterface'); $authConfigSource = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock();
$this->config->setConfigSource($configSource); $this->config->setConfigSource($configSource);
$this->config->setAuthConfigSource($authConfigSource); $this->config->setAuthConfigSource($authConfigSource);
@ -119,7 +119,7 @@ class GitHubDriverTest extends TestCase
$identifier = 'v0.0.0'; $identifier = 'v0.0.0';
$sha = 'SOMESHA'; $sha = 'SOMESHA';
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->any()) $io->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -162,7 +162,7 @@ class GitHubDriverTest extends TestCase
$identifier = 'feature/3.2-foo'; $identifier = 'feature/3.2-foo';
$sha = 'SOMESHA'; $sha = 'SOMESHA';
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->any()) $io->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -222,7 +222,7 @@ class GitHubDriverTest extends TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->any()) $io->expects($this->any())
->method('isInteractive') ->method('isInteractive')
->will($this->returnValue(false)); ->will($this->returnValue(false));

View File

@ -28,7 +28,7 @@ class HgDriverTest extends TestCase
public function setUp() public function setUp()
{ {
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->home = $this->getUniqueTmpDirectory(); $this->home = $this->getUniqueTmpDirectory();
$this->config = new Config(); $this->config = new Config();
$this->config->merge(array( $this->config->merge(array(

View File

@ -91,12 +91,12 @@ class PerforceDriverTest extends TestCase
protected function getMockIOInterface() protected function getMockIOInterface()
{ {
return $this->getMock('Composer\IO\IOInterface'); return $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
} }
protected function getMockProcessExecutor() protected function getMockProcessExecutor()
{ {
return $this->getMock('Composer\Util\ProcessExecutor'); return $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
} }
protected function getMockRemoteFilesystem() protected function getMockRemoteFilesystem()

View File

@ -45,13 +45,13 @@ class SvnDriverTest extends TestCase
*/ */
public function testWrongCredentialsInUrl() public function testWrongCredentialsInUrl()
{ {
$console = $this->getMock('Composer\IO\IOInterface'); $console = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$output = "svn: OPTIONS of 'https://corp.svn.local/repo':"; $output = "svn: OPTIONS of 'https://corp.svn.local/repo':";
$output .= " authorization failed: Could not authenticate to server:"; $output .= " authorization failed: Could not authenticate to server:";
$output .= " rejected Basic challenge (https://corp.svn.local/)"; $output .= " rejected Basic challenge (https://corp.svn.local/)";
$process = $this->getMock('Composer\Util\ProcessExecutor'); $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$process->expects($this->at(1)) $process->expects($this->at(1))
->method('execute') ->method('execute')
->will($this->returnValue(1)); ->will($this->returnValue(1));
@ -95,7 +95,7 @@ class SvnDriverTest extends TestCase
public function testSupport($url, $assertion) public function testSupport($url, $assertion)
{ {
$config = new Config(); $config = new Config();
$result = SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $config, $url); $result = SvnDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url);
$this->assertEquals($assertion, $result); $this->assertEquals($assertion, $result);
} }
} }

View File

@ -53,7 +53,7 @@ class BitbucketTest extends TestCase
->getMock() ->getMock()
; ;
$this->config = $this->getMock('Composer\Config'); $this->config = $this->getMockBuilder('Composer\Config')->getMock();
$this->time = time(); $this->time = time();
@ -258,7 +258,7 @@ class BitbucketTest extends TestCase
private function setExpectationsForStoringAccessToken($removeBasicAuth = false) private function setExpectationsForStoringAccessToken($removeBasicAuth = false)
{ {
$configSourceMock = $this->getMock('Composer\Config\ConfigSourceInterface'); $configSourceMock = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock();
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getConfigSource') ->method('getConfigSource')
->willReturn($configSourceMock); ->willReturn($configSourceMock);
@ -267,7 +267,7 @@ class BitbucketTest extends TestCase
->method('removeConfigSetting') ->method('removeConfigSetting')
->with('bitbucket-oauth.' . $this->origin); ->with('bitbucket-oauth.' . $this->origin);
$authConfigSourceMock = $this->getMock('Composer\Config\ConfigSourceInterface'); $authConfigSourceMock = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock();
$this->config->expects($this->atLeastOnce()) $this->config->expects($this->atLeastOnce())
->method('getAuthConfigSource') ->method('getAuthConfigSource')
->willReturn($authConfigSourceMock); ->willReturn($authConfigSourceMock);

View File

@ -117,7 +117,7 @@ class GitHubTest extends TestCase
private function getConfigMock() private function getConfigMock()
{ {
return $this->getMock('Composer\Config'); return $this->getMockBuilder('Composer\Config')->getMock();
} }
private function getRemoteFilesystemMock() private function getRemoteFilesystemMock()

View File

@ -126,7 +126,7 @@ class GitLabTest extends TestCase
private function getConfigMock() private function getConfigMock()
{ {
return $this->getMock('Composer\Config'); return $this->getMockBuilder('Composer\Config')->getMock();
} }
private function getRemoteFilesystemMock() private function getRemoteFilesystemMock()

View File

@ -33,7 +33,7 @@ class PerforceTest extends TestCase
protected function setUp() protected function setUp()
{ {
$this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $this->processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$this->repoConfig = $this->getTestRepoConfig(); $this->repoConfig = $this->getTestRepoConfig();
$this->io = $this->getMockIOInterface(); $this->io = $this->getMockIOInterface();
$this->createNewPerforceWithWindowsFlag(true); $this->createNewPerforceWithWindowsFlag(true);
@ -59,7 +59,7 @@ class PerforceTest extends TestCase
public function getMockIOInterface() public function getMockIOInterface()
{ {
return $this->getMock('Composer\IO\IOInterface'); return $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
} }
protected function createNewPerforceWithWindowsFlag($flag) protected function createNewPerforceWithWindowsFlag($flag)
@ -618,7 +618,7 @@ class PerforceTest extends TestCase
public function testCheckServerExists() public function testCheckServerExists()
{ {
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedCommand = 'p4 -p perforce.does.exist:port info -s'; $expectedCommand = 'p4 -p perforce.does.exist:port info -s';
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -639,7 +639,7 @@ class PerforceTest extends TestCase
*/ */
public function testCheckServerClientError() public function testCheckServerClientError()
{ {
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$expectedCommand = 'p4 -p perforce.does.exist:port info -s'; $expectedCommand = 'p4 -p perforce.does.exist:port info -s';
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
@ -707,7 +707,7 @@ class PerforceTest extends TestCase
public function testCleanupClientSpecShouldDeleteClient() public function testCleanupClientSpecShouldDeleteClient()
{ {
$fs = $this->getMock('Composer\Util\Filesystem'); $fs = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$this->perforce->setFilesystem($fs); $this->perforce->setFilesystem($fs);
$testClient = $this->perforce->getClient(); $testClient = $this->perforce->getClient();

View File

@ -37,7 +37,7 @@ class ProcessExecutorTest extends TestCase
public function testUseIOIsNotNullAndIfNotCaptured() public function testUseIOIsNotNullAndIfNotCaptured()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->once()) $io->expects($this->once())
->method('write') ->method('write')
->with($this->equalTo('foo'.PHP_EOL), false); ->with($this->equalTo('foo'.PHP_EOL), false);

View File

@ -19,7 +19,7 @@ class RemoteFilesystemTest extends TestCase
{ {
public function testGetOptionsForUrl() public function testGetOptionsForUrl()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthentication') ->method('hasAuthentication')
@ -32,7 +32,7 @@ class RemoteFilesystemTest extends TestCase
public function testGetOptionsForUrlWithAuthorization() public function testGetOptionsForUrlWithAuthorization()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthentication') ->method('hasAuthentication')
@ -57,7 +57,7 @@ class RemoteFilesystemTest extends TestCase
public function testGetOptionsForUrlWithStreamOptions() public function testGetOptionsForUrlWithStreamOptions()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthentication') ->method('hasAuthentication')
@ -74,7 +74,7 @@ class RemoteFilesystemTest extends TestCase
public function testGetOptionsForUrlWithCallOptionsKeepsHeader() public function testGetOptionsForUrlWithCallOptionsKeepsHeader()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io $io
->expects($this->once()) ->expects($this->once())
->method('hasAuthentication') ->method('hasAuthentication')
@ -101,14 +101,14 @@ class RemoteFilesystemTest extends TestCase
public function testCallbackGetFileSize() public function testCallbackGetFileSize()
{ {
$fs = new RemoteFilesystem($this->getMock('Composer\IO\IOInterface')); $fs = new RemoteFilesystem($this->getMockBuilder('Composer\IO\IOInterface')->getMock());
$this->callCallbackGet($fs, STREAM_NOTIFY_FILE_SIZE_IS, 0, '', 0, 0, 20); $this->callCallbackGet($fs, STREAM_NOTIFY_FILE_SIZE_IS, 0, '', 0, 0, 20);
$this->assertAttributeEquals(20, 'bytesMax', $fs); $this->assertAttributeEquals(20, 'bytesMax', $fs);
} }
public function testCallbackGetNotifyProgress() public function testCallbackGetNotifyProgress()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io $io
->expects($this->once()) ->expects($this->once())
->method('overwriteError') ->method('overwriteError')
@ -124,7 +124,7 @@ class RemoteFilesystemTest extends TestCase
public function testCallbackGetPassesThrough404() public function testCallbackGetPassesThrough404()
{ {
$fs = new RemoteFilesystem($this->getMock('Composer\IO\IOInterface')); $fs = new RemoteFilesystem($this->getMockBuilder('Composer\IO\IOInterface')->getMock());
$this->assertNull($this->callCallbackGet($fs, STREAM_NOTIFY_FAILURE, 0, 'HTTP/1.1 404 Not Found', 404, 0, 0)); $this->assertNull($this->callCallbackGet($fs, STREAM_NOTIFY_FAILURE, 0, 'HTTP/1.1 404 Not Found', 404, 0, 0));
} }
@ -134,7 +134,7 @@ class RemoteFilesystemTest extends TestCase
*/ */
public function testCaptureAuthenticationParamsFromUrl() public function testCaptureAuthenticationParamsFromUrl()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$io->expects($this->once()) $io->expects($this->once())
->method('setAuthentication') ->method('setAuthentication')
->with($this->equalTo('github.com'), $this->equalTo('user'), $this->equalTo('pass')); ->with($this->equalTo('github.com'), $this->equalTo('user'), $this->equalTo('pass'));
@ -150,14 +150,14 @@ class RemoteFilesystemTest extends TestCase
public function testGetContents() public function testGetContents()
{ {
$fs = new RemoteFilesystem($this->getMock('Composer\IO\IOInterface')); $fs = new RemoteFilesystem($this->getMockBuilder('Composer\IO\IOInterface')->getMock());
$this->assertContains('testGetContents', $fs->getContents('http://example.org', 'file://'.__FILE__)); $this->assertContains('testGetContents', $fs->getContents('http://example.org', 'file://'.__FILE__));
} }
public function testCopy() public function testCopy()
{ {
$fs = new RemoteFilesystem($this->getMock('Composer\IO\IOInterface')); $fs = new RemoteFilesystem($this->getMockBuilder('Composer\IO\IOInterface')->getMock());
$file = tempnam(sys_get_temp_dir(), 'c'); $file = tempnam(sys_get_temp_dir(), 'c');
$this->assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file)); $this->assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file));
@ -171,7 +171,7 @@ class RemoteFilesystemTest extends TestCase
*/ */
public function testGetOptionsForUrlCreatesSecureTlsDefaults() public function testGetOptionsForUrlCreatesSecureTlsDefaults()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$res = $this->callGetOptionsForUrl($io, array('example.org', array('ssl' => array('cafile' => '/some/path/file.crt'))), array(), 'http://www.example.org'); $res = $this->callGetOptionsForUrl($io, array('example.org', array('ssl' => array('cafile' => '/some/path/file.crt'))), array(), 'http://www.example.org');