diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 649c700c8..5ff23921c 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -94,6 +94,10 @@ class ClassMapGenerator if ($blacklist && preg_match($blacklist, strtr(realpath($filePath), '\\', '/'))) { continue; } + // check non-realpath of file for directories symlink in project dir + if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) { + continue; + } $classes = self::findClasses($filePath); diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 4f0409a60..7a4251084 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -167,6 +167,13 @@ class ArrayRepository extends BaseRepository { $packageId = $package->getUniqueName(); + if ($package instanceof AliasPackage) { + $aliasedPackage = $package->getAliasOf(); + if ($this === $aliasedPackage->getRepository()) { + $this->removePackage($aliasedPackage); + } + } + foreach ($this->getPackages() as $key => $repoPackage) { if ($packageId === $repoPackage->getUniqueName()) { array_splice($this->packages, $key, 1); diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 4fa326241..37d434fa8 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -22,8 +22,8 @@ class ApplicationTest extends TestCase { $application = new Application; - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $index = 0; $inputMock->expects($this->at($index++)) @@ -75,8 +75,8 @@ class ApplicationTest extends TestCase $application->add(new \Composer\Command\SelfUpdateCommand); - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $index = 0; $inputMock->expects($this->at($index++)) diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 22ceec030..c676263a8 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -23,6 +23,7 @@ use Composer\Repository\InstalledRepositoryInterface; use Composer\Installer\InstallationManager; use Composer\Config; use Composer\EventDispatcher\EventDispatcher; +use Composer\Util\Platform; use PHPUnit_Framework_MockObject_MockObject as MockObject; class AutoloadGeneratorTest extends TestCase @@ -92,7 +93,7 @@ class AutoloadGeneratorTest extends TestCase $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload'; $this->ensureDirectoryExistsAndClear($this->vendorDir); - $this->config = $this->getMock('Composer\Config'); + $this->config = $this->getMockBuilder('Composer\Config')->getMock(); $this->configValueMap = array( 'vendor-dir' => function () use ($that) { @@ -127,7 +128,7 @@ class AutoloadGeneratorTest extends TestCase 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') ->disableOriginalConstructor() @@ -1292,6 +1293,7 @@ EOF; ), 'classmap' => array('composersrc/'), 'exclude-from-classmap' => array( + '/composersrc/foo/bar/', '/composersrc/excludedTests/', '/composersrc/ClassToExclude.php', '/composersrc/*/excluded/excsubpath', @@ -1326,6 +1328,18 @@ EOF; file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/foo.php', 'workingDir.'/composersrc/long/excluded/excsubpath/bar.php', 'fs->ensureDirectoryExists($this->workingDir.'/forks/bar/src/exclude'); + $this->fs->ensureDirectoryExists($this->workingDir.'/composersrc/foo'); + + file_put_contents($this->workingDir.'/forks/bar/src/exclude/FooExclClass.php', 'workingDir.'/forks/bar/'; + $link = $this->workingDir.'/composersrc/foo/bar/'; + $command = Platform::isWindows() + ? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) + : 'ln -s "' . $target . '" "' . $link; + exec($command); + $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); // Assert that autoload_classmap.php was correctly generated. diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index 4c6757489..9830fd7de 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -35,12 +35,11 @@ class CacheTest extends TestCase $this->finder = $this->getMockBuilder('Symfony\Component\Finder\Finder')->disableOriginalConstructor()->getMock(); - $io = $this->getMock('Composer\IO\IOInterface'); - $this->cache = $this->getMock( - 'Composer\Cache', - array('getFinder'), - array($io, $this->root) - ); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $this->cache = $this->getMockBuilder('Composer\Cache') + ->setMethods(array('getFinder')) + ->setConstructorArgs(array($io, $this->root)) + ->getMock(); $this->cache ->expects($this->any()) ->method('getFinder') diff --git a/tests/Composer/Test/Command/RunScriptCommandTest.php b/tests/Composer/Test/Command/RunScriptCommandTest.php index 83ec63b76..53478b323 100644 --- a/tests/Composer/Test/Command/RunScriptCommandTest.php +++ b/tests/Composer/Test/Command/RunScriptCommandTest.php @@ -28,7 +28,7 @@ class RunScriptCommandTest extends TestCase { $scriptName = 'testScript'; - $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $input ->method('getOption') ->will($this->returnValueMap(array( @@ -48,7 +48,7 @@ class RunScriptCommandTest extends TestCase ->with('command') ->willReturn(false); - $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $expectedDevMode = $dev || !$noDev; diff --git a/tests/Composer/Test/ComposerTest.php b/tests/Composer/Test/ComposerTest.php index df00c36f7..aabe1deab 100644 --- a/tests/Composer/Test/ComposerTest.php +++ b/tests/Composer/Test/ComposerTest.php @@ -20,7 +20,7 @@ class ComposerTest extends TestCase public function testSetGetPackage() { $composer = new Composer(); - $package = $this->getMock('Composer\Package\RootPackageInterface'); + $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); $composer->setPackage($package); $this->assertSame($package, $composer->getPackage()); @@ -47,8 +47,8 @@ class ComposerTest extends TestCase public function testSetGetDownloadManager() { $composer = new Composer(); - $io = $this->getMock('Composer\IO\IOInterface'); - $manager = $this->getMock('Composer\Downloader\DownloadManager', array(), array($io)); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')->setConstructorArgs(array($io))->getMock(); $composer->setDownloadManager($manager); $this->assertSame($manager, $composer->getDownloadManager()); @@ -57,7 +57,7 @@ class ComposerTest extends TestCase public function testSetGetInstallationManager() { $composer = new Composer(); - $manager = $this->getMock('Composer\Installer\InstallationManager'); + $manager = $this->getMockBuilder('Composer\Installer\InstallationManager')->getMock(); $composer->setInstallationManager($manager); $this->assertSame($manager, $composer->getInstallationManager()); diff --git a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php index c97ccb053..39b53cf8f 100644 --- a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php @@ -18,13 +18,13 @@ class ArchiveDownloaderTest extends TestCase { public function testGetFileName() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getDistUrl') ->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->setAccessible(true); @@ -39,12 +39,12 @@ class ArchiveDownloaderTest extends TestCase $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->setAccessible(true); $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); } @@ -55,12 +55,12 @@ class ArchiveDownloaderTest extends TestCase $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->setAccessible(true); $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); } @@ -71,12 +71,12 @@ class ArchiveDownloaderTest extends TestCase $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->setAccessible(true); $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); } @@ -90,14 +90,14 @@ class ArchiveDownloaderTest extends TestCase $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->setAccessible(true); $type = strpos($url, 'tar') ? 'tar' : 'zip'; $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()) ->method('getDistReference') ->will($this->returnValue('ref')); @@ -127,14 +127,14 @@ class ArchiveDownloaderTest extends TestCase $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->setAccessible(true); $url = $url . '.' . $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()) ->method('getDistReference') ->will($this->returnValue('ref')); @@ -151,4 +151,12 @@ class ArchiveDownloaderTest extends TestCase 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()) + ); + } } diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php index 9c2aa7f40..222e541d7 100644 --- a/tests/Composer/Test/Downloader/DownloadManagerTest.php +++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php @@ -22,8 +22,8 @@ class DownloadManagerTest extends TestCase public function setUp() { - $this->filesystem = $this->getMock('Composer\Util\Filesystem'); - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } public function testSetGetDownloader() diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 9b9f7b671..1c51c2abe 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -20,8 +20,8 @@ class FileDownloaderTest extends TestCase { protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $rfs = null, $filesystem = null) { - $io = $io ?: $this->getMock('Composer\IO\IOInterface'); - $config = $config ?: $this->getMock('Composer\Config'); + $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock(); $rfs = $rfs ?: $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock(); return new FileDownloader($io, $config, $eventDispatcher, $cache, $rfs, $filesystem); @@ -32,7 +32,7 @@ class FileDownloaderTest extends TestCase */ public function testDownloadForPackageWithoutDistReference() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getDistUrl') ->will($this->returnValue(null)) @@ -44,7 +44,7 @@ class FileDownloaderTest extends TestCase public function testDownloadToExistingFile() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getDistUrl') ->will($this->returnValue('url')) @@ -74,7 +74,7 @@ class FileDownloaderTest extends TestCase public function testGetFileName() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getDistUrl') ->will($this->returnValue('http://example.com/script.js')) @@ -89,7 +89,7 @@ class FileDownloaderTest extends TestCase public function testDownloadButFileIsUnsaved() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getDistUrl') ->will($this->returnValue($distUrl = 'http://example.com/script.js')) @@ -104,7 +104,7 @@ class FileDownloaderTest extends TestCase ; $path = $this->getUniqueTmpDirectory(); - $ioMock = $this->getMock('Composer\IO\IOInterface'); + $ioMock = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $ioMock->expects($this->any()) ->method('write') ->will($this->returnCallback(function ($messages, $newline = true) use ($path) { @@ -137,7 +137,7 @@ class FileDownloaderTest extends TestCase { $expectedTtl = '99999999'; - $configMock = $this->getMock('Composer\Config'); + $configMock = $this->getMockBuilder('Composer\Config')->getMock(); $configMock ->expects($this->at(0)) ->method('get') @@ -166,7 +166,7 @@ class FileDownloaderTest extends TestCase public function testDownloadFileWithInvalidChecksum() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getDistUrl') ->will($this->returnValue($distUrl = 'http://example.com/script.js')) @@ -183,7 +183,7 @@ class FileDownloaderTest extends TestCase ->method('getDistUrls') ->will($this->returnValue(array($distUrl))) ; - $filesystem = $this->getMock('Composer\Util\Filesystem'); + $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $path = $this->getUniqueTmpDirectory(); $downloader = $this->getDownloader(null, null, null, null, null, $filesystem); diff --git a/tests/Composer/Test/Downloader/FossilDownloaderTest.php b/tests/Composer/Test/Downloader/FossilDownloaderTest.php index 68babfd1d..2e1de934d 100644 --- a/tests/Composer/Test/Downloader/FossilDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FossilDownloaderTest.php @@ -37,10 +37,10 @@ class FossilDownloaderTest extends TestCase protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null) { - $io = $io ?: $this->getMock('Composer\IO\IOInterface'); - $config = $config ?: $this->getMock('Composer\Config'); - $executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); - $filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); + $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock(); + $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); + $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); return new FossilDownloader($io, $config, $executor, $filesystem); } @@ -50,7 +50,7 @@ class FossilDownloaderTest extends TestCase */ public function testDownloadForPackageWithoutSourceReference() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getSourceReference') ->will($this->returnValue(null)); @@ -61,14 +61,14 @@ class FossilDownloaderTest extends TestCase public function testDownload() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('trunk')); $packageMock->expects($this->once()) ->method('getSourceUrls') ->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\''); $processExecutor->expects($this->at(0)) @@ -97,8 +97,8 @@ class FossilDownloaderTest extends TestCase */ public function testUpdateforPackageWithoutSourceReference() { - $initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); - $sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); + $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $sourcePackageMock->expects($this->once()) ->method('getSourceReference') ->will($this->returnValue(null)); @@ -116,14 +116,14 @@ class FossilDownloaderTest extends TestCase touch($file); } - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('trunk')); $packageMock->expects($this->any()) ->method('getSourceUrls') ->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"); $processExecutor->expects($this->at(0)) @@ -144,12 +144,12 @@ class FossilDownloaderTest extends TestCase { $expectedResetCommand = $this->getCmd('cd \'composerPath\' && fossil status'); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->any()) ->method('execute') ->with($this->equalTo($expectedResetCommand)); - $filesystem = $this->getMock('Composer\Util\Filesystem'); + $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem->expects($this->any()) ->method('removeDirectory') ->with($this->equalTo('composerPath')) diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 20e609712..588d4d2ee 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -60,9 +60,9 @@ class GitDownloaderTest extends TestCase protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null) { - $io = $io ?: $this->getMock('Composer\IO\IOInterface'); - $executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); - $filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); + $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); + $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $config = $this->setupConfig($config); return new GitDownloader($io, $config, $executor, $filesystem); @@ -73,7 +73,7 @@ class GitDownloaderTest extends TestCase */ public function testDownloadForPackageWithoutSourceReference() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getSourceReference') ->will($this->returnValue(null)); @@ -84,7 +84,7 @@ class GitDownloaderTest extends TestCase public function testDownload() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('1234567890123456789012345678901234567890')); @@ -97,7 +97,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('dev-master')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') @@ -135,7 +135,7 @@ class GitDownloaderTest extends TestCase public function testDownloadWithCache() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('1234567890123456789012345678901234567890')); @@ -148,7 +148,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('dev-master')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') @@ -201,7 +201,7 @@ class GitDownloaderTest extends TestCase public function testDownloadUsesVariousProtocolsAndSetsPushUrlForGithub() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -214,7 +214,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('1.0.0')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') @@ -285,7 +285,7 @@ class GitDownloaderTest extends TestCase */ public function testDownloadAndSetPushUrlUseCustomVariousProtocolsForGithub($protocols, $url, $pushUrl) { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -298,7 +298,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('1.0.0')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') @@ -338,14 +338,14 @@ class GitDownloaderTest extends TestCase 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"); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); $packageMock->expects($this->any()) ->method('getSourceUrls') ->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)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) @@ -368,8 +368,8 @@ class GitDownloaderTest extends TestCase */ public function testUpdateforPackageWithoutSourceReference() { - $initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); - $sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); + $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $sourcePackageMock->expects($this->once()) ->method('getSourceReference') ->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)"); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -392,7 +392,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('1.0.0')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->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)"); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -444,7 +444,7 @@ class GitDownloaderTest extends TestCase $packageMock->expects($this->any()) ->method('getPrettyVersion') ->will($this->returnValue('1.0.0')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->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)"); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); $packageMock->expects($this->any()) ->method('getSourceUrls') ->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)) ->method('execute') ->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)"); $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()) ->method('getSourceReference') ->will($this->returnValue('ref')); $packageMock->expects($this->any()) ->method('getSourceUrls') ->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)) ->method('execute') ->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"); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->any()) ->method('execute') ->with($this->equalTo($expectedGitResetCommand)) ->will($this->returnValue(0)); - $filesystem = $this->getMock('Composer\Util\Filesystem'); + $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem->expects($this->any()) ->method('removeDirectory') ->with($this->equalTo('composerPath')) diff --git a/tests/Composer/Test/Downloader/HgDownloaderTest.php b/tests/Composer/Test/Downloader/HgDownloaderTest.php index 6b660e383..537d98775 100644 --- a/tests/Composer/Test/Downloader/HgDownloaderTest.php +++ b/tests/Composer/Test/Downloader/HgDownloaderTest.php @@ -37,10 +37,10 @@ class HgDownloaderTest extends TestCase protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null) { - $io = $io ?: $this->getMock('Composer\IO\IOInterface'); - $config = $config ?: $this->getMock('Composer\Config'); - $executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor'); - $filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem'); + $io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $config = $config ?: $this->getMockBuilder('Composer\Config')->getMock(); + $executor = $executor ?: $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); + $filesystem = $filesystem ?: $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); return new HgDownloader($io, $config, $executor, $filesystem); } @@ -50,7 +50,7 @@ class HgDownloaderTest extends TestCase */ public function testDownloadForPackageWithoutSourceReference() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->once()) ->method('getSourceReference') ->will($this->returnValue(null)); @@ -61,14 +61,14 @@ class HgDownloaderTest extends TestCase public function testDownload() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); $packageMock->expects($this->once()) ->method('getSourceUrls') ->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\''); $processExecutor->expects($this->at(0)) @@ -91,8 +91,8 @@ class HgDownloaderTest extends TestCase */ public function testUpdateforPackageWithoutSourceReference() { - $initialPackageMock = $this->getMock('Composer\Package\PackageInterface'); - $sourcePackageMock = $this->getMock('Composer\Package\PackageInterface'); + $initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $sourcePackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $sourcePackageMock->expects($this->once()) ->method('getSourceReference') ->will($this->returnValue(null)); @@ -105,14 +105,14 @@ class HgDownloaderTest extends TestCase { $fs = new Filesystem; $fs->ensureDirectoryExists($this->workingDir.'/.hg'); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); $packageMock->expects($this->any()) ->method('getSourceUrls') ->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"); $processExecutor->expects($this->at(0)) @@ -133,12 +133,12 @@ class HgDownloaderTest extends TestCase { $expectedResetCommand = $this->getCmd('cd \'composerPath\' && hg st'); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->any()) ->method('execute') ->with($this->equalTo($expectedResetCommand)); - $filesystem = $this->getMock('Composer\Util\Filesystem'); + $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem->expects($this->any()) ->method('removeDirectory') ->with($this->equalTo('composerPath')) diff --git a/tests/Composer/Test/Downloader/PerforceDownloaderTest.php b/tests/Composer/Test/Downloader/PerforceDownloaderTest.php index 6ec44d3c3..3fae0f7af 100644 --- a/tests/Composer/Test/Downloader/PerforceDownloaderTest.php +++ b/tests/Composer/Test/Downloader/PerforceDownloaderTest.php @@ -62,7 +62,7 @@ class PerforceDownloaderTest extends TestCase protected function getMockProcessExecutor() { - return $this->getMock('Composer\Util\ProcessExecutor'); + return $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); } protected function getConfig() @@ -76,12 +76,12 @@ class PerforceDownloaderTest extends TestCase protected function getMockIoInterface() { - return $this->getMock('Composer\IO\IOInterface'); + return $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } 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)); return $package; @@ -94,10 +94,10 @@ class PerforceDownloaderTest extends TestCase protected function getMockRepository(array $repoConfig, IOInterface $io, Config $config) { - $class = 'Composer\Repository\VcsRepository'; - $methods = array('getRepoConfig'); - $args = array($repoConfig, $io, $config); - $repository = $this->getMock($class, $methods, $args); + $repository = $this->getMockBuilder('Composer\Repository\VcsRepository') + ->setMethods(array('getRepoConfig')) + ->setConstructorArgs(array($repoConfig, $io, $config)) + ->getMock(); $repository->expects($this->any())->method('getRepoConfig')->will($this->returnValue($repoConfig)); return $repository; diff --git a/tests/Composer/Test/Downloader/XzDownloaderTest.php b/tests/Composer/Test/Downloader/XzDownloaderTest.php index ba81cdaaf..fc33adcf4 100644 --- a/tests/Composer/Test/Downloader/XzDownloaderTest.php +++ b/tests/Composer/Test/Downloader/XzDownloaderTest.php @@ -46,7 +46,7 @@ class XzDownloaderTest extends TestCase public function testErrorMessages() { - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getDistUrl') ->will($this->returnValue($distUrl = 'file://'.__FILE__)) @@ -60,8 +60,8 @@ class XzDownloaderTest extends TestCase ->will($this->returnValue(array())) ; - $io = $this->getMock('Composer\IO\IOInterface'); - $config = $this->getMock('Composer\Config'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $config = $this->getMockBuilder('Composer\Config')->getMock(); $config->expects($this->any()) ->method('get') ->with('vendor-dir') diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php index 9c437e786..3d4ebac7b 100644 --- a/tests/Composer/Test/Downloader/ZipDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -28,8 +28,8 @@ class ZipDownloaderTest extends TestCase public function setUp() { $this->testDir = $this->getUniqueTmpDirectory(); - $this->io = $this->getMock('Composer\IO\IOInterface'); - $this->config = $this->getMock('Composer\Config'); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $this->config = $this->getMockBuilder('Composer\Config')->getMock(); } public function tearDown() @@ -78,7 +78,7 @@ class ZipDownloaderTest extends TestCase ->with('vendor-dir') ->will($this->returnValue($this->testDir)); - $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $packageMock->expects($this->any()) ->method('getDistUrl') ->will($this->returnValue($distUrl = 'file://'.__FILE__)) @@ -118,7 +118,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -144,7 +144,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -169,7 +169,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasZipArchive', true); $downloader = new MockedZipDownloader($this->io, $this->config); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -193,7 +193,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', false); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->will($this->returnValue(1)); @@ -210,7 +210,7 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', false); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->will($this->returnValue(0)); @@ -229,12 +229,12 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', true); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->will($this->returnValue(1)); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -261,12 +261,12 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', true); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') ->will($this->returnValue(1)); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -289,12 +289,12 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', true); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->atLeastOnce()) ->method('execute') ->will($this->returnValue(0)); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); @@ -321,12 +321,12 @@ class ZipDownloaderTest extends TestCase $this->setPrivateProperty('hasSystemUnzip', true); $this->setPrivateProperty('hasZipArchive', true); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->atLeastOnce()) ->method('execute') ->will($this->returnValue(1)); - $zipArchive = $this->getMock('ZipArchive'); + $zipArchive = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchive->expects($this->at(0)) ->method('open') ->will($this->returnValue(true)); diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index b1e0a7c2c..7f0327d9c 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -31,7 +31,7 @@ class EventDispatcherTest extends TestCase */ public function testListenerExceptionsAreCaught() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $dispatcher = $this->getDispatcherStubForListenersTest(array( 'Composer\Test\EventDispatcher\EventDispatcherTest::call', ), $io); @@ -56,7 +56,7 @@ class EventDispatcherTest extends TestCase */ public function testDispatcherCanConvertScriptEventToCommandEventForListener() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $dispatcher = $this->getDispatcherStubForListenersTest(array( 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsCommandEvent', ), $io); @@ -66,7 +66,7 @@ class EventDispatcherTest extends TestCase public function testDispatcherDoesNotAttemptConversionForListenerWithoutTypehint() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $dispatcher = $this->getDispatcherStubForListenersTest(array( 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsVariableEvent', ), $io); @@ -80,11 +80,11 @@ class EventDispatcherTest extends TestCase */ public function testDispatcherCanExecuteSingleCommandLineScript($command) { - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $this->createComposerInstance(), - $this->getMock('Composer\IO\IOInterface'), + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $process, )) ->setMethods(array('getListeners')) @@ -118,17 +118,17 @@ class EventDispatcherTest extends TestCase $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')))); $composer->setPackage($package); $composer->setRepositoryManager($this->getRepositoryManagerMockForDevModePassingTest()); - $composer->setInstallationManager($this->getMock('Composer\Installer\InstallationManager')); + $composer->setInstallationManager($this->getMockBuilder('Composer\Installer\InstallationManager')->getMock()); $dispatcher = new EventDispatcher( $composer, - $this->getMock('Composer\IO\IOInterface'), - $this->getMock('Composer\Util\ProcessExecutor') + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), + $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock() ); $event = $this->getMockBuilder('Composer\Script\Event') @@ -169,7 +169,7 @@ class EventDispatcherTest extends TestCase ->will($this->returnValue(array())); $generator ->method('createLoader') - ->will($this->returnValue($this->getMock('Composer\Autoload\ClassLoader'))); + ->will($this->returnValue($this->getMockBuilder('Composer\Autoload\ClassLoader')->getMock())); return $generator; } @@ -181,7 +181,7 @@ class EventDispatcherTest extends TestCase ->setMethods(array('getLocalRepository')) ->getMock(); - $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $repo = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock(); $repo ->method('getCanonicalPackages') ->will($this->returnValue(array())); @@ -195,7 +195,7 @@ class EventDispatcherTest extends TestCase public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack() { - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $this->createComposerInstance(), @@ -231,7 +231,7 @@ class EventDispatcherTest extends TestCase public function testDispatcherCanExecuteComposerScriptGroups() { - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $composer = $this->createComposerInstance(), @@ -279,11 +279,11 @@ class EventDispatcherTest extends TestCase */ public function testDispatcherDetectInfiniteRecursion() { - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $composer = $this->createComposerInstance(), - $io = $this->getMock('Composer\IO\IOInterface'), + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $process, )) ->setMethods(array( @@ -339,7 +339,7 @@ class EventDispatcherTest extends TestCase $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $this->createComposerInstance(), - $io = $this->getMock('Composer\IO\IOInterface'), + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), new ProcessExecutor($io), )) ->setMethods(array('getListeners')) @@ -366,7 +366,7 @@ class EventDispatcherTest extends TestCase $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $this->createComposerInstance(), - $io = $this->getMock('Composer\IO\IOInterface'), + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), new ProcessExecutor, )) ->setMethods(array('getListeners')) @@ -396,11 +396,11 @@ class EventDispatcherTest extends TestCase public function testDispatcherInstallerEvents() { - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') ->setConstructorArgs(array( $this->createComposerInstance(), - $this->getMock('Composer\IO\IOInterface'), + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $process, )) ->setMethods(array('getListeners')) @@ -410,7 +410,7 @@ class EventDispatcherTest extends TestCase ->method('getListeners') ->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(); $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock(); $request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock(); @@ -444,7 +444,7 @@ class EventDispatcherTest extends TestCase $composer = new Composer; $config = new Config; $composer->setConfig($config); - $package = $this->getMock('Composer\Package\RootPackageInterface'); + $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); $composer->setPackage($package); return $composer; diff --git a/tests/Composer/Test/IO/ConsoleIOTest.php b/tests/Composer/Test/IO/ConsoleIOTest.php index 9c9ca8902..f44369dba 100644 --- a/tests/Composer/Test/IO/ConsoleIOTest.php +++ b/tests/Composer/Test/IO/ConsoleIOTest.php @@ -20,7 +20,7 @@ class ConsoleIOTest extends TestCase { 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)) ->method('isInteractive') ->will($this->returnValue(true)); @@ -28,8 +28,8 @@ class ConsoleIOTest extends TestCase ->method('isInteractive') ->will($this->returnValue(false)); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); @@ -39,15 +39,15 @@ class ConsoleIOTest extends TestCase public function testWrite() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $outputMock->expects($this->once()) ->method('getVerbosity') ->willReturn(OutputInterface::VERBOSITY_NORMAL); $outputMock->expects($this->once()) ->method('write') ->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->write('some information about something', false); @@ -55,8 +55,8 @@ class ConsoleIOTest extends TestCase public function testWriteError() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\ConsoleOutputInterface')->getMock(); $outputMock->expects($this->once()) ->method('getVerbosity') ->willReturn(OutputInterface::VERBOSITY_NORMAL); @@ -66,7 +66,7 @@ class ConsoleIOTest extends TestCase $outputMock->expects($this->once()) ->method('write') ->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->writeError('some information about something', false); @@ -74,8 +74,8 @@ class ConsoleIOTest extends TestCase public function testWriteWithMultipleLineStringWhenDebugging() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $outputMock->expects($this->once()) ->method('getVerbosity') ->willReturn(OutputInterface::VERBOSITY_NORMAL); @@ -90,7 +90,7 @@ class ConsoleIOTest extends TestCase }), $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); $startTime = microtime(true); @@ -102,8 +102,8 @@ class ConsoleIOTest extends TestCase public function testOverwrite() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $outputMock->expects($this->any()) ->method('getVerbosity') @@ -130,7 +130,7 @@ class ConsoleIOTest extends TestCase ->method('write') ->with($this->equalTo('something longer than initial (34)')); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->write('something (strlen = 23)'); @@ -140,10 +140,10 @@ class ConsoleIOTest extends TestCase public function testAsk() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); - $setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock(); + $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $helperMock ->expects($this->once()) @@ -168,10 +168,10 @@ class ConsoleIOTest extends TestCase public function testAskConfirmation() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); - $setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock(); + $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $helperMock ->expects($this->once()) @@ -196,10 +196,10 @@ class ConsoleIOTest extends TestCase public function testAskAndValidate() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); - $setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock(); + $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $helperMock ->expects($this->once()) @@ -227,10 +227,10 @@ class ConsoleIOTest extends TestCase public function testSelect() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper'); - $setMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')->getMock(); + $setMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $helperMock ->expects($this->once()) @@ -257,9 +257,9 @@ class ConsoleIOTest extends TestCase public function testSetAndgetAuthentication() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); @@ -272,9 +272,9 @@ class ConsoleIOTest extends TestCase public function testGetAuthenticationWhenDidNotSet() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); @@ -286,9 +286,9 @@ class ConsoleIOTest extends TestCase public function testHasAuthentication() { - $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); - $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet'); + $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $helperMock = $this->getMockBuilder('Symfony\Component\Console\Helper\HelperSet')->getMock(); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->setAuthentication('repoName', 'l3l0', 'passwd'); diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index bded74c1c..beb4e4bf5 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -24,7 +24,7 @@ class InstallationManagerTest extends TestCase public function setUp() { - $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock(); } public function testAddGetInstaller() diff --git a/tests/Composer/Test/Installer/InstallerEventTest.php b/tests/Composer/Test/Installer/InstallerEventTest.php index a8603542a..8c99ba565 100644 --- a/tests/Composer/Test/Installer/InstallerEventTest.php +++ b/tests/Composer/Test/Installer/InstallerEventTest.php @@ -19,13 +19,13 @@ class InstallerEventTest extends TestCase { public function testGetter() { - $composer = $this->getMock('Composer\Composer'); - $io = $this->getMock('Composer\IO\IOInterface'); - $policy = $this->getMock('Composer\DependencyResolver\PolicyInterface'); + $composer = $this->getMockBuilder('Composer\Composer')->getMock(); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $policy = $this->getMockBuilder('Composer\DependencyResolver\PolicyInterface')->getMock(); $pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock(); $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->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); $this->assertSame('EVENT_NAME', $event->getName()); diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index 7ab76402d..41581f712 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -57,8 +57,8 @@ class LibraryInstallerTest extends TestCase ->getMock(); $this->composer->setDownloadManager($this->dm); - $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock(); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } protected function tearDown() diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php index 5474f3815..1a6b7a264 100644 --- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php +++ b/tests/Composer/Test/Installer/MetapackageInstallerTest.php @@ -23,9 +23,9 @@ class MetapackageInstallerTest extends TestCase 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(); } diff --git a/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php b/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php index 48809bd33..7c80935cd 100644 --- a/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php +++ b/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php @@ -25,7 +25,7 @@ class SuggestedPackagesReporterTest extends TestCase protected function setUp() { - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io); } @@ -185,9 +185,9 @@ class SuggestedPackagesReporterTest extends TestCase */ public function testOutputSkipInstalledPackages() { - $repository = $this->getMock('Composer\Repository\RepositoryInterface'); - $package1 = $this->getMock('Composer\Package\PackageInterface'); - $package2 = $this->getMock('Composer\Package\PackageInterface'); + $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock(); + $package1 = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); + $package2 = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $package1->expects($this->once()) ->method('getNames') @@ -219,7 +219,7 @@ class SuggestedPackagesReporterTest extends TestCase */ public function testOutputNotGettingInstalledPackagesWhenNoSuggestions() { - $repository = $this->getMock('Composer\Repository\RepositoryInterface'); + $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock(); $repository->expects($this->exactly(0)) ->method('getPackages'); diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 468d8fbbd..8614495ee 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -57,10 +57,12 @@ class InstallerTest extends TestCase */ 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)); - $config = $this->getMock('Composer\Config'); + $downloadManager = $this->getMockBuilder('Composer\Downloader\DownloadManager') + ->setConstructorArgs(array($io)) + ->getMock(); + $config = $this->getMockBuilder('Composer\Config')->getMock(); $repositoryManager = new RepositoryManager($io, $config); $repositoryManager->setLocalRepository(new InstalledArrayRepository()); @@ -202,7 +204,9 @@ class InstallerTest extends TestCase $composer->setLocker($locker); $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->setEventDispatcher($eventDispatcher); diff --git a/tests/Composer/Test/Package/BasePackageTest.php b/tests/Composer/Test/Package/BasePackageTest.php index 35bcb9d02..32a8cd844 100644 --- a/tests/Composer/Test/Package/BasePackageTest.php +++ b/tests/Composer/Test/Package/BasePackageTest.php @@ -20,7 +20,7 @@ class BasePackageTest extends TestCase public function testSetSameRepository() { $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo')); - $repository = $this->getMock('Composer\Repository\RepositoryInterface'); + $repository = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock(); $package->setRepository($repository); try { @@ -37,8 +37,8 @@ class BasePackageTest extends TestCase { $package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo')); - $package->setRepository($this->getMock('Composer\Repository\RepositoryInterface')); - $package->setRepository($this->getMock('Composer\Repository\RepositoryInterface')); + $package->setRepository($this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock()); + $package->setRepository($this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock()); } /** diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index a791b7f06..bd1c29c13 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -31,7 +31,7 @@ class ArrayDumperTest extends TestCase public function setUp() { $this->dumper = new ArrayDumper(); - $this->package = $this->getMock('Composer\Package\CompletePackageInterface'); + $this->package = $this->getMockBuilder('Composer\Package\CompletePackageInterface')->getMock(); $this->packageExpects('getTransportOptions', array()); } @@ -56,7 +56,7 @@ class ArrayDumperTest extends TestCase public function testRootPackage() { - $this->package = $this->getMock('Composer\Package\RootPackageInterface'); + $this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); $this ->packageExpects('getMinimumStability', 'dev') @@ -92,7 +92,7 @@ class ArrayDumperTest extends TestCase */ 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('isAbandoned', $value); diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index c1115becd..8896f81af 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -23,7 +23,7 @@ class ValidatingArrayLoaderTest extends TestCase */ public function testLoadSuccess($config) { - $internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); + $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock(); $internalLoader ->expects($this->once()) ->method('load') @@ -171,7 +171,7 @@ class ValidatingArrayLoaderTest extends TestCase */ 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); try { $loader->load($config); @@ -189,7 +189,7 @@ class ValidatingArrayLoaderTest extends TestCase */ 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->load($config); @@ -209,7 +209,7 @@ class ValidatingArrayLoaderTest extends TestCase return; } - $internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); + $internalLoader = $this->getMockBuilder('Composer\Package\Loader\LoaderInterface')->getMock(); $internalLoader ->expects($this->once()) ->method('load') diff --git a/tests/Composer/Test/Package/Version/VersionSelectorTest.php b/tests/Composer/Test/Package/Version/VersionSelectorTest.php index c9fc9a3e6..d3e831e5c 100644 --- a/tests/Composer/Test/Package/Version/VersionSelectorTest.php +++ b/tests/Composer/Test/Package/Version/VersionSelectorTest.php @@ -198,7 +198,7 @@ class VersionSelectorTest extends TestCase $versionSelector = new VersionSelector($pool); $versionParser = new VersionParser(); - $package = $this->getMock('\Composer\Package\PackageInterface'); + $package = $this->getMockBuilder('\Composer\Package\PackageInterface')->getMock(); $package ->expects($this->any()) ->method('getPrettyVersion') @@ -275,6 +275,6 @@ class VersionSelectorTest extends TestCase private function createMockPool() { - return $this->getMock('Composer\DependencyResolver\Pool', array(), array(), '', true); + return $this->getMockBuilder('Composer\DependencyResolver\Pool')->getMock(); } } diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index 57ba7f13f..26fc63efa 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -80,7 +80,7 @@ class PluginInstallerTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock(); $rm = $this->getMockBuilder('Composer\Repository\RepositoryManager') ->disableOriginalConstructor() @@ -89,14 +89,14 @@ class PluginInstallerTest extends TestCase ->method('getLocalRepository') ->will($this->returnValue($this->repository)); - $im = $this->getMock('Composer\Installer\InstallationManager'); + $im = $this->getMockBuilder('Composer\Installer\InstallationManager')->getMock(); $im->expects($this->any()) ->method('getInstallPath') ->will($this->returnCallback(function ($package) { 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(); $this->autoloadGenerator = new AutoloadGenerator($dispatcher); diff --git a/tests/Composer/Test/Repository/ArrayRepositoryTest.php b/tests/Composer/Test/Repository/ArrayRepositoryTest.php index 799e76a5b..5927325ee 100644 --- a/tests/Composer/Test/Repository/ArrayRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArrayRepositoryTest.php @@ -68,7 +68,7 @@ class ArrayRepositoryTest extends TestCase $this->assertEquals('bar', $bar[0]->getName()); } - public function testAutomaticallyAddAliasedPackage() + public function testAutomaticallyAddAndRemoveAliasedPackage() { $repo = new ArrayRepository(); @@ -80,6 +80,10 @@ class ArrayRepositoryTest extends TestCase $this->assertCount(2, $repo); $this->assertTrue($repo->hasPackage($this->getPackage('foo', '1'))); $this->assertTrue($repo->hasPackage($this->getPackage('foo', '2'))); + + $repo->removePackage($alias); + + $this->assertCount(0, $repo); } public function testSearch() diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 4017bfe51..38b459730 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -31,18 +31,14 @@ class ComposerRepositoryTest extends TestCase 'url' => 'http://example.org', ); - $repository = $this->getMock( - 'Composer\Repository\ComposerRepository', - array( - 'loadRootServerFile', - 'createPackage', - ), - array( + $repository = $this->getMockBuilder('Composer\Repository\ComposerRepository') + ->setMethods(array('loadRootServerFile', 'createPackage')) + ->setConstructorArgs(array( $repoConfig, new NullIO, FactoryMock::createConfig(), - ) - ); + )) + ->getMock(); $repository ->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()) ->method('isPackageAcceptable') ->will($this->returnValue(true)); diff --git a/tests/Composer/Test/Repository/RepositoryFactoryTest.php b/tests/Composer/Test/Repository/RepositoryFactoryTest.php index 8ce66cfd5..e6d811fe9 100644 --- a/tests/Composer/Test/Repository/RepositoryFactoryTest.php +++ b/tests/Composer/Test/Repository/RepositoryFactoryTest.php @@ -20,8 +20,8 @@ class RepositoryFactoryTest extends TestCase public function testManagerWithAllRepositoryTypes() { $manager = RepositoryFactory::manager( - $this->getMock('Composer\IO\IOInterface'), - $this->getMock('Composer\Config') + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), + $this->getMockBuilder('Composer\Config')->getMock() ); $ref = new \ReflectionProperty($manager, 'repositoryClasses'); diff --git a/tests/Composer/Test/Repository/RepositoryManagerTest.php b/tests/Composer/Test/Repository/RepositoryManagerTest.php index 735fbd049..a5739f32d 100644 --- a/tests/Composer/Test/Repository/RepositoryManagerTest.php +++ b/tests/Composer/Test/Repository/RepositoryManagerTest.php @@ -36,13 +36,13 @@ class RepositoryManagerTest extends TestCase public function testPrepend() { $rm = new RepositoryManager( - $this->getMock('Composer\IO\IOInterface'), - $this->getMock('Composer\Config'), + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), + $this->getMockBuilder('Composer\Config')->getMock(), $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() ); - $repository1 = $this->getMock('Composer\Repository\RepositoryInterface'); - $repository2 = $this->getMock('Composer\Repository\RepositoryInterface'); + $repository1 = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock(); + $repository2 = $this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock(); $rm->addRepository($repository1); $rm->prependRepository($repository2); @@ -59,8 +59,8 @@ class RepositoryManagerTest extends TestCase } $rm = new RepositoryManager( - $this->getMock('Composer\IO\IOInterface'), - $config = $this->getMock('Composer\Config', array('get')), + $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), + $config = $this->getMockBuilder('Composer\Config')->setMethods(array('get'))->getMock(), $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() ); diff --git a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php index 970abf34b..f9e73b5eb 100644 --- a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php @@ -64,7 +64,7 @@ class FossilDriverTest extends TestCase public function testSupport($url, $assertion) { $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); } } diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php index 86e362c6f..b35bb8867 100644 --- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php @@ -35,7 +35,7 @@ class GitBitbucketDriverTest extends TestCase protected function setUp() { - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->home = $this->getUniqueTmpDirectory(); diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 30179a1a9..35e2f64c8 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -48,7 +48,7 @@ class GitHubDriverTest extends TestCase $identifier = 'v0.0.0'; $sha = 'SOMESHA'; - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->any()) ->method('isInteractive') ->will($this->returnValue(true)); @@ -57,7 +57,7 @@ class GitHubDriverTest extends TestCase ->setConstructorArgs(array($io)) ->getMock(); - $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $process->expects($this->any()) ->method('execute') ->will($this->returnValue(1)); @@ -86,8 +86,8 @@ class GitHubDriverTest extends TestCase ->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"}')); - $configSource = $this->getMock('Composer\Config\ConfigSourceInterface'); - $authConfigSource = $this->getMock('Composer\Config\ConfigSourceInterface'); + $configSource = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock(); + $authConfigSource = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock(); $this->config->setConfigSource($configSource); $this->config->setAuthConfigSource($authConfigSource); @@ -119,7 +119,7 @@ class GitHubDriverTest extends TestCase $identifier = 'v0.0.0'; $sha = 'SOMESHA'; - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->any()) ->method('isInteractive') ->will($this->returnValue(true)); @@ -162,7 +162,7 @@ class GitHubDriverTest extends TestCase $identifier = 'feature/3.2-foo'; $sha = 'SOMESHA'; - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->any()) ->method('isInteractive') ->will($this->returnValue(true)); @@ -222,7 +222,7 @@ class GitHubDriverTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->any()) ->method('isInteractive') ->will($this->returnValue(false)); diff --git a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php index 8f496da9c..441ce19c2 100644 --- a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php @@ -28,7 +28,7 @@ class HgDriverTest extends TestCase public function setUp() { - $this->io = $this->getMock('Composer\IO\IOInterface'); + $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->home = $this->getUniqueTmpDirectory(); $this->config = new Config(); $this->config->merge(array( diff --git a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php index 02b97501c..02a6e89e5 100644 --- a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php @@ -91,12 +91,12 @@ class PerforceDriverTest extends TestCase protected function getMockIOInterface() { - return $this->getMock('Composer\IO\IOInterface'); + return $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } protected function getMockProcessExecutor() { - return $this->getMock('Composer\Util\ProcessExecutor'); + return $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); } protected function getMockRemoteFilesystem() diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index a3a9855db..1106c9df4 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -45,13 +45,13 @@ class SvnDriverTest extends TestCase */ 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 .= " authorization failed: Could not authenticate to server:"; $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)) ->method('execute') ->will($this->returnValue(1)); @@ -95,7 +95,7 @@ class SvnDriverTest extends TestCase public function testSupport($url, $assertion) { $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); } } diff --git a/tests/Composer/Test/Util/BitbucketTest.php b/tests/Composer/Test/Util/BitbucketTest.php index c7f95e859..4323a15f5 100644 --- a/tests/Composer/Test/Util/BitbucketTest.php +++ b/tests/Composer/Test/Util/BitbucketTest.php @@ -53,7 +53,7 @@ class BitbucketTest extends TestCase ->getMock() ; - $this->config = $this->getMock('Composer\Config'); + $this->config = $this->getMockBuilder('Composer\Config')->getMock(); $this->time = time(); @@ -258,7 +258,7 @@ class BitbucketTest extends TestCase private function setExpectationsForStoringAccessToken($removeBasicAuth = false) { - $configSourceMock = $this->getMock('Composer\Config\ConfigSourceInterface'); + $configSourceMock = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock(); $this->config->expects($this->once()) ->method('getConfigSource') ->willReturn($configSourceMock); @@ -267,7 +267,7 @@ class BitbucketTest extends TestCase ->method('removeConfigSetting') ->with('bitbucket-oauth.' . $this->origin); - $authConfigSourceMock = $this->getMock('Composer\Config\ConfigSourceInterface'); + $authConfigSourceMock = $this->getMockBuilder('Composer\Config\ConfigSourceInterface')->getMock(); $this->config->expects($this->atLeastOnce()) ->method('getAuthConfigSource') ->willReturn($authConfigSourceMock); diff --git a/tests/Composer/Test/Util/GitHubTest.php b/tests/Composer/Test/Util/GitHubTest.php index 5cba3b5ba..28d00ce69 100644 --- a/tests/Composer/Test/Util/GitHubTest.php +++ b/tests/Composer/Test/Util/GitHubTest.php @@ -117,7 +117,7 @@ class GitHubTest extends TestCase private function getConfigMock() { - return $this->getMock('Composer\Config'); + return $this->getMockBuilder('Composer\Config')->getMock(); } private function getRemoteFilesystemMock() diff --git a/tests/Composer/Test/Util/GitLabTest.php b/tests/Composer/Test/Util/GitLabTest.php index 8a5abe125..27f46b4ad 100644 --- a/tests/Composer/Test/Util/GitLabTest.php +++ b/tests/Composer/Test/Util/GitLabTest.php @@ -126,7 +126,7 @@ class GitLabTest extends TestCase private function getConfigMock() { - return $this->getMock('Composer\Config'); + return $this->getMockBuilder('Composer\Config')->getMock(); } private function getRemoteFilesystemMock() diff --git a/tests/Composer/Test/Util/PerforceTest.php b/tests/Composer/Test/Util/PerforceTest.php index 9c25adaa1..7d27b013e 100644 --- a/tests/Composer/Test/Util/PerforceTest.php +++ b/tests/Composer/Test/Util/PerforceTest.php @@ -34,7 +34,7 @@ class PerforceTest extends TestCase protected function setUp() { - $this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $this->processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $this->repoConfig = $this->getTestRepoConfig(); $this->io = $this->getMockIOInterface(); $this->createNewPerforceWithWindowsFlag(true); @@ -60,7 +60,7 @@ class PerforceTest extends TestCase public function getMockIOInterface() { - return $this->getMock('Composer\IO\IOInterface'); + return $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); } protected function createNewPerforceWithWindowsFlag($flag) @@ -619,7 +619,7 @@ class PerforceTest extends TestCase 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'; $processExecutor->expects($this->at(0)) @@ -640,7 +640,7 @@ class PerforceTest extends TestCase */ 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'; $processExecutor->expects($this->at(0)) @@ -708,7 +708,7 @@ class PerforceTest extends TestCase public function testCleanupClientSpecShouldDeleteClient() { - $fs = $this->getMock('Composer\Util\Filesystem'); + $fs = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $this->perforce->setFilesystem($fs); $testClient = $this->perforce->getClient(); diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 985ed2240..4a18c24e7 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -37,7 +37,7 @@ class ProcessExecutorTest extends TestCase public function testUseIOIsNotNullAndIfNotCaptured() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->once()) ->method('write') ->with($this->equalTo('foo'.PHP_EOL), false); diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index 066a9275f..7da88bc8a 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -19,7 +19,7 @@ class RemoteFilesystemTest extends TestCase { public function testGetOptionsForUrl() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io ->expects($this->once()) ->method('hasAuthentication') @@ -32,7 +32,7 @@ class RemoteFilesystemTest extends TestCase public function testGetOptionsForUrlWithAuthorization() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io ->expects($this->once()) ->method('hasAuthentication') @@ -57,7 +57,7 @@ class RemoteFilesystemTest extends TestCase public function testGetOptionsForUrlWithStreamOptions() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io ->expects($this->once()) ->method('hasAuthentication') @@ -74,7 +74,7 @@ class RemoteFilesystemTest extends TestCase public function testGetOptionsForUrlWithCallOptionsKeepsHeader() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io ->expects($this->once()) ->method('hasAuthentication') @@ -101,14 +101,14 @@ class RemoteFilesystemTest extends TestCase 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->assertAttributeEquals(20, 'bytesMax', $fs); } public function testCallbackGetNotifyProgress() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io ->expects($this->once()) ->method('overwriteError') @@ -124,7 +124,7 @@ class RemoteFilesystemTest extends TestCase 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)); } @@ -134,7 +134,7 @@ class RemoteFilesystemTest extends TestCase */ public function testCaptureAuthenticationParamsFromUrl() { - $io = $this->getMock('Composer\IO\IOInterface'); + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $io->expects($this->once()) ->method('setAuthentication') ->with($this->equalTo('github.com'), $this->equalTo('user'), $this->equalTo('pass')); @@ -150,14 +150,14 @@ class RemoteFilesystemTest extends TestCase 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__)); } 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'); $this->assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file)); @@ -171,7 +171,7 @@ class RemoteFilesystemTest extends TestCase */ 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');