From 0caa616e6c498e0ffb4a6363d0ee695698956068 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 18 Feb 2019 14:03:23 +0100 Subject: [PATCH] Fix test warnings --- tests/Composer/Test/ApplicationTest.php | 2 +- tests/Composer/Test/CacheTest.php | 6 ++++-- .../Test/Downloader/FileDownloaderTest.php | 8 ++++---- .../Test/Downloader/GitDownloaderTest.php | 16 ++++++++-------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 8739a5004..39d462544 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -47,7 +47,7 @@ class ApplicationTest extends TestCase $index = 0; $outputMock->expects($this->at($index++)) - ->method("writeError"); + ->method("write"); if (extension_loaded('xdebug')) { $outputMock->expects($this->at($index++)) diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index 50c767752..a8d3eae4a 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -20,6 +20,7 @@ class CacheTest extends TestCase private $files; private $root; private $finder; + private $filesystem; private $cache; public function setUp() @@ -34,11 +35,12 @@ class CacheTest extends TestCase } $this->finder = $this->getMockBuilder('Symfony\Component\Finder\Finder')->disableOriginalConstructor()->getMock(); + $this->filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $this->cache = $this->getMockBuilder('Composer\Cache') ->setMethods(array('getFinder')) - ->setConstructorArgs(array($io, $this->root)) + ->setConstructorArgs(array($io, $this->root, 'a-z0-9.', $this->filesystem)) ->getMock(); $this->cache ->expects($this->any()) @@ -105,7 +107,7 @@ class CacheTest extends TestCase public function testClearCache() { - $this->finder + $this->filesystem ->method('removeDirectory') ->with($this->root) ->willReturn(true); diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 89c538eab..7c4259ca3 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -223,7 +223,7 @@ class FileDownloaderTest extends TestCase public function testDowngradeShowsAppropriateMessage() { - $oldPackage = $this->getMock('Composer\Package\PackageInterface'); + $oldPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $oldPackage->expects($this->any()) ->method('getFullPrettyVersion') ->will($this->returnValue('1.2.0')); @@ -231,7 +231,7 @@ class FileDownloaderTest extends TestCase ->method('getVersion') ->will($this->returnValue('1.2.0.0')); - $newPackage = $this->getMock('Composer\Package\PackageInterface'); + $newPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $newPackage->expects($this->any()) ->method('getFullPrettyVersion') ->will($this->returnValue('1.0.0')); @@ -245,7 +245,7 @@ class FileDownloaderTest extends TestCase ->method('getDistUrls') ->will($this->returnValue(array($distUrl))); - $ioMock = $this->getMock('Composer\IO\IOInterface'); + $ioMock = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $ioMock->expects($this->at(0)) ->method('writeError') ->with($this->stringContains('Downloading')); @@ -256,7 +256,7 @@ class FileDownloaderTest extends TestCase $path = $this->getUniqueTmpDirectory(); touch($path.'_script.js'); - $filesystem = $this->getMock('Composer\Util\Filesystem'); + $filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock(); $filesystem->expects($this->once()) ->method('removeDirectory') ->will($this->returnValue(true)); diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index b5d0054de..b9a85a666 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -604,7 +604,7 @@ composer https://github.com/old/url (push) public function testDowngradeShowsAppropriateMessage() { - $oldPackage = $this->getMock('Composer\Package\PackageInterface'); + $oldPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $oldPackage->expects($this->any()) ->method('getVersion') ->will($this->returnValue('1.2.0.0')); @@ -618,7 +618,7 @@ composer https://github.com/old/url (push) ->method('getSourceUrls') ->will($this->returnValue(array('/foo/bar', 'https://github.com/composer/composer'))); - $newPackage = $this->getMock('Composer\Package\PackageInterface'); + $newPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $newPackage->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -632,12 +632,12 @@ composer https://github.com/old/url (push) ->method('getFullPrettyVersion') ->will($this->returnValue('1.0.0')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->any()) ->method('execute') ->will($this->returnValue(0)); - $ioMock = $this->getMock('Composer\IO\IOInterface'); + $ioMock = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $ioMock->expects($this->at(0)) ->method('writeError') ->with($this->stringContains('Downgrading')); @@ -649,7 +649,7 @@ composer https://github.com/old/url (push) public function testNotUsingDowngradingWithReferences() { - $oldPackage = $this->getMock('Composer\Package\PackageInterface'); + $oldPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $oldPackage->expects($this->any()) ->method('getVersion') ->will($this->returnValue('dev-ref')); @@ -660,7 +660,7 @@ composer https://github.com/old/url (push) ->method('getSourceUrls') ->will($this->returnValue(array('/foo/bar', 'https://github.com/composer/composer'))); - $newPackage = $this->getMock('Composer\Package\PackageInterface'); + $newPackage = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock(); $newPackage->expects($this->any()) ->method('getSourceReference') ->will($this->returnValue('ref')); @@ -671,12 +671,12 @@ composer https://github.com/old/url (push) ->method('getVersion') ->will($this->returnValue('dev-ref2')); - $processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); + $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->any()) ->method('execute') ->will($this->returnValue(0)); - $ioMock = $this->getMock('Composer\IO\IOInterface'); + $ioMock = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); $ioMock->expects($this->at(0)) ->method('writeError') ->with($this->stringContains('updating'));