From d942c65e0cc65659d60b7e07d4c1e230aaa1aeba Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 11 Sep 2020 11:27:26 +0200 Subject: [PATCH] Fix more warnings --- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 6 +++--- tests/Composer/Test/CacheTest.php | 4 ++-- tests/Composer/Test/Downloader/ArchiveDownloaderTest.php | 2 +- tests/Composer/Test/Downloader/FileDownloaderTest.php | 2 +- tests/Composer/Test/Downloader/XzDownloaderTest.php | 2 +- tests/Composer/Test/Installer/LibraryInstallerTest.php | 4 ++-- .../Composer/Test/Package/Archiver/ArchiveManagerTest.php | 4 ++-- tests/Composer/Test/Util/ErrorHandlerTest.php | 6 +++++- tests/Composer/Test/Util/FilesystemTest.php | 8 ++++---- tests/Composer/Test/Util/RemoteFilesystemTest.php | 2 +- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index dd084ad9f..ad38b3c8f 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -941,8 +941,8 @@ EOF; $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_real.php'); $this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_static_functions_with_removed_include_paths_and_autolad_files.php', $this->vendorDir.'/composer/autoload_static.php'); - $this->assertFileNotExists($this->vendorDir.'/composer/autoload_files.php'); - $this->assertFileNotExists($this->vendorDir.'/composer/include_paths.php'); + $this->assertFileDoesNotExist($this->vendorDir.'/composer/autoload_files.php'); + $this->assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php'); } public function testFilesAutoloadOrderByDependencies() @@ -1223,7 +1223,7 @@ EOF; $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12'); - $this->assertFileNotExists($this->vendorDir."/composer/include_paths.php"); + $this->assertFileDoesNotExist($this->vendorDir."/composer/include_paths.php"); } public function testPreAndPostEventsAreDispatchedDuringAutoloadDump() diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index dffa8390a..d2a655f3a 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -72,7 +72,7 @@ class CacheTest extends TestCase $this->cache->gc(600, 1024 * 1024 * 1024); for ($i = 1; $i < 4; $i++) { - $this->assertFileNotExists("{$this->root}/cached.file{$i}.zip"); + $this->assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); } $this->assertFileExists("{$this->root}/cached.file0.zip"); } @@ -101,7 +101,7 @@ class CacheTest extends TestCase $this->cache->gc(600, 1500); for ($i = 0; $i < 3; $i++) { - $this->assertFileNotExists("{$this->root}/cached.file{$i}.zip"); + $this->assertFileDoesNotExist("{$this->root}/cached.file{$i}.zip"); } $this->assertFileExists("{$this->root}/cached.file3.zip"); } diff --git a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php index 977fb6574..e2cc87bc9 100644 --- a/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ArchiveDownloaderTest.php @@ -36,7 +36,7 @@ class ArchiveDownloaderTest extends TestCase ->will($this->returnValue('/vendor')); $first = $method->invoke($downloader, $packageMock, '/path'); - $this->assertRegExp('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first); + $this->assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $first); $this->assertSame($first, $method->invoke($downloader, $packageMock, '/path')); } diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index c47acf6aa..d419cb1b1 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -98,7 +98,7 @@ class FileDownloaderTest extends TestCase ->with('vendor-dir') ->will($this->returnValue('/vendor')); - $this->assertRegExp('#/vendor/composer/tmp-[a-z0-9]+\.js#', $method->invoke($downloader, $packageMock, '/path')); + $this->assertMatchesRegularExpression('#/vendor/composer/tmp-[a-z0-9]+\.js#', $method->invoke($downloader, $packageMock, '/path')); } public function testDownloadButFileIsUnsaved() diff --git a/tests/Composer/Test/Downloader/XzDownloaderTest.php b/tests/Composer/Test/Downloader/XzDownloaderTest.php index 6996d67f6..1b28e707a 100644 --- a/tests/Composer/Test/Downloader/XzDownloaderTest.php +++ b/tests/Composer/Test/Downloader/XzDownloaderTest.php @@ -77,7 +77,7 @@ class XzDownloaderTest extends TestCase $this->fail('Download of invalid tarball should throw an exception'); } catch (\RuntimeException $e) { - $this->assertRegexp('/(File format not recognized|Unrecognized archive format)/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/(File format not recognized|Unrecognized archive format)/i', $e->getMessage()); } } } diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index f2f2e89e6..4bf81eada 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -71,7 +71,7 @@ class LibraryInstallerTest extends TestCase $this->fs->removeDirectory($this->vendorDir); new LibraryInstaller($this->io, $this->composer); - $this->assertFileNotExists($this->vendorDir); + $this->assertFileDoesNotExist($this->vendorDir); } public function testInstallerCreationShouldNotCreateBinDirectory() @@ -79,7 +79,7 @@ class LibraryInstallerTest extends TestCase $this->fs->removeDirectory($this->binDir); new LibraryInstaller($this->io, $this->composer); - $this->assertFileNotExists($this->binDir); + $this->assertFileDoesNotExist($this->binDir); } public function testIsInstalled() diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index 9204e6fa6..a93fe6de6 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -68,7 +68,7 @@ class ArchiveManagerTest extends ArchiverTest $this->assertFileExists($target); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); - $this->assertFileNotExists($tmppath); + $this->assertFileDoesNotExist($tmppath); unlink($target); } @@ -90,7 +90,7 @@ class ArchiveManagerTest extends ArchiverTest $this->assertFileExists($target); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); - $this->assertFileNotExists($tmppath); + $this->assertFileDoesNotExist($tmppath); unlink($target); } diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php index ef501542e..c7651b80a 100644 --- a/tests/Composer/Test/Util/ErrorHandlerTest.php +++ b/tests/Composer/Test/Util/ErrorHandlerTest.php @@ -35,7 +35,11 @@ class ErrorHandlerTest extends TestCase */ public function testErrorHandlerCaptureNotice() { - $this->setExpectedException('\ErrorException', 'Undefined index: baz'); + if (PHP_VERSION_ID >= 80000) { + $this->setExpectedException('\ErrorException', 'Undefined array key "baz"'); + } else { + $this->setExpectedException('\ErrorException', 'Undefined index: baz'); + } $array = array('foo' => 'bar'); $array['baz']; diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index f3fb30278..0fb4babd8 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -168,7 +168,7 @@ class FilesystemTest extends TestCase $fs = new Filesystem; $this->assertTrue($fs->removeDirectoryPhp($this->workingDir)); - $this->assertFileNotExists($this->workingDir . "/level1/level2/hello.txt"); + $this->assertFileDoesNotExist($this->workingDir . "/level1/level2/hello.txt"); } public function testFileSize() @@ -247,7 +247,7 @@ class FilesystemTest extends TestCase $fs = new Filesystem(); $result = $fs->unlink($symlinked); $this->assertTrue($result); - $this->assertFileNotExists($symlinked); + $this->assertFileDoesNotExist($symlinked); } /** @@ -279,8 +279,8 @@ class FilesystemTest extends TestCase $result = $fs->removeDirectory($symlinkedTrailingSlash); $this->assertTrue($result); - $this->assertFileNotExists($symlinkedTrailingSlash); - $this->assertFileNotExists($symlinked); + $this->assertFileDoesNotExist($symlinkedTrailingSlash); + $this->assertFileDoesNotExist($symlinked); } public function testJunctions() diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index 8fe685fbc..b6b062b12 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -253,7 +253,7 @@ class RemoteFilesystemTest extends TestCase $res = $this->callGetOptionsForUrl($io, array('example.org', array('ssl' => array('cafile' => '/some/path/file.crt'))), array(), 'http://www.example.org'); $this->assertTrue(isset($res['ssl']['ciphers'])); - $this->assertRegExp('|!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA|', $res['ssl']['ciphers']); + $this->assertMatchesRegularExpression('|!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA|', $res['ssl']['ciphers']); $this->assertTrue($res['ssl']['verify_peer']); $this->assertTrue($res['ssl']['SNI_enabled']); $this->assertEquals(7, $res['ssl']['verify_depth']);