1
0
Fork 0

Merge pull request #9054 from GrahamCampbell/php8

Fix tests on PHP 8.0
pull/9203/head
Jordi Boggiano 2020-09-11 11:58:15 +02:00 committed by GitHub
commit c1b0e6c293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 35 additions and 49 deletions

View File

@ -38,31 +38,31 @@ jobs:
os: [ubuntu-latest] os: [ubuntu-latest]
experimental: [false] experimental: [false]
include: include:
- php-version: 5.3 - php-version: "5.3"
dependencies: highest dependencies: highest
os: ubuntu-latest os: ubuntu-latest
experimental: false experimental: false
- php-version: 5.3 - php-version: "5.3"
dependencies: lowest dependencies: lowest
os: ubuntu-latest os: ubuntu-latest
experimental: false experimental: false
- php-version: 7.4 - php-version: "7.4"
dependencies: highest dependencies: highest
os: ubuntu-latest os: ubuntu-latest
experimental: false experimental: false
- php-version: 7.4 - php-version: "7.4"
os: windows-latest os: windows-latest
dependencies: locked dependencies: locked
experimental: false experimental: false
- php-version: 7.4 - php-version: "7.4"
os: macos-latest os: macos-latest
dependencies: locked dependencies: locked
experimental: false experimental: false
- php-version: 8.0 - php-version: "8.0"
dependencies: lowest-ignore dependencies: lowest-ignore
os: ubuntu-latest os: ubuntu-latest
experimental: true experimental: true
- php-version: 8.0 - php-version: "8.0"
dependencies: highest-ignore dependencies: highest-ignore
os: ubuntu-latest os: ubuntu-latest
experimental: true experimental: true
@ -83,7 +83,7 @@ jobs:
elif [ "${{ matrix.php-version }}" = "7.1" ]; then elif [ "${{ matrix.php-version }}" = "7.1" ]; then
echo "::set-env name=SYMFONY_PHPUNIT_VERSION::7.5"; echo "::set-env name=SYMFONY_PHPUNIT_VERSION::7.5";
elif [ "${{ matrix.php-version }}" = "8.0" ]; then elif [ "${{ matrix.php-version }}" = "8.0" ]; then
echo "::set-env name=SYMFONY_PHPUNIT_VERSION::9.2"; echo "::set-env name=SYMFONY_PHPUNIT_VERSION::9.3";
else else
echo "::set-env name=SYMFONY_PHPUNIT_VERSION::8.3"; echo "::set-env name=SYMFONY_PHPUNIT_VERSION::8.3";
fi fi
@ -95,25 +95,7 @@ jobs:
extensions: "intl, zip" extensions: "intl, zip"
ini-values: "memory_limit=-1, phar.readonly=0" ini-values: "memory_limit=-1, phar.readonly=0"
php-version: "${{ matrix.php-version }}" php-version: "${{ matrix.php-version }}"
tools: composer:v2
- name: "Update to latest Composer snapshot"
if: "!startsWith(matrix.os, 'windows')"
run: "sudo -i composer self-update --snapshot"
- name: "Update to latest Composer snapshot on Windows"
if: "startsWith(matrix.os, 'windows')"
run: "composer self-update --snapshot"
- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}-${{ hashFiles('**/composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}"
- name: "Handle lowest dependencies update" - name: "Handle lowest dependencies update"
if: "contains(matrix.dependencies, 'lowest')" if: "contains(matrix.dependencies, 'lowest')"
@ -136,9 +118,7 @@ jobs:
- name: "Require latest PHPUnitBridge for PHP 8" - name: "Require latest PHPUnitBridge for PHP 8"
if: "matrix.php-version == '8.0'" if: "matrix.php-version == '8.0'"
run: | run: composer require --no-update --dev symfony/phpunit-bridge:^5.1
composer require --no-update --dev symfony/phpunit-bridge:^5.1
composer config -g platform-check false
- name: "Update Symfony's PHPUnitBridge to latest available for the current PHP always as it is not really a dependency of the project" - name: "Update Symfony's PHPUnitBridge to latest available for the current PHP always as it is not really a dependency of the project"
run: "composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge" run: "composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge"

View File

@ -50,6 +50,7 @@ jobs:
run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}" run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}"
- name: Run PHPStan - name: Run PHPStan
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
run: | run: |
bin/composer require --dev phpstan/phpstan:^0.12.37 phpunit/phpunit:^7.5.20 --with-all-dependencies bin/composer require --dev phpstan/phpstan:^0.12.42 phpunit/phpunit:^7.5.20 --with-all-dependencies
vendor/bin/phpstan analyse --configuration=phpstan/config.neon vendor/bin/phpstan analyse --configuration=phpstan/config.neon

View File

@ -26,6 +26,7 @@ parameters:
# BC with older PHPUnit # BC with older PHPUnit
- '~^Call to an undefined static method Composer\\Test\\PolyfillTestCase::setExpectedException\(\)\.$~' - '~^Call to an undefined static method Composer\\Test\\PolyfillTestCase::setExpectedException\(\)\.$~'
- '~^Call to an undefined method Composer\\Test\\[a-zA-Z0-9\\]+::(assertFileDoesNotExist|assertMatchesRegularExpression)\(\)\.$~'
paths: paths:
- ../src - ../src

View File

@ -941,8 +941,8 @@ EOF;
$this->assertFileContentEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); $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_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->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->assertFileDoesNotExist($this->vendorDir.'/composer/autoload_files.php');
$this->assertFileNotExists($this->vendorDir.'/composer/include_paths.php'); $this->assertFileDoesNotExist($this->vendorDir.'/composer/include_paths.php');
} }
public function testFilesAutoloadOrderByDependencies() public function testFilesAutoloadOrderByDependencies()
@ -1223,7 +1223,7 @@ EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12'); $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() public function testPreAndPostEventsAreDispatchedDuringAutoloadDump()

View File

@ -72,7 +72,7 @@ class CacheTest extends TestCase
$this->cache->gc(600, 1024 * 1024 * 1024); $this->cache->gc(600, 1024 * 1024 * 1024);
for ($i = 1; $i < 4; $i++) { 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"); $this->assertFileExists("{$this->root}/cached.file0.zip");
} }
@ -101,7 +101,7 @@ class CacheTest extends TestCase
$this->cache->gc(600, 1500); $this->cache->gc(600, 1500);
for ($i = 0; $i < 3; $i++) { 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"); $this->assertFileExists("{$this->root}/cached.file3.zip");
} }

View File

@ -36,7 +36,7 @@ class ArchiveDownloaderTest extends TestCase
->will($this->returnValue('/vendor')); ->will($this->returnValue('/vendor'));
$first = $method->invoke($downloader, $packageMock, '/path'); $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')); $this->assertSame($first, $method->invoke($downloader, $packageMock, '/path'));
} }

View File

@ -98,7 +98,7 @@ class FileDownloaderTest extends TestCase
->with('vendor-dir') ->with('vendor-dir')
->will($this->returnValue('/vendor')); ->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() public function testDownloadButFileIsUnsaved()

View File

@ -77,7 +77,7 @@ class XzDownloaderTest extends TestCase
$this->fail('Download of invalid tarball should throw an exception'); $this->fail('Download of invalid tarball should throw an exception');
} catch (\RuntimeException $e) { } 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());
} }
} }
} }

View File

@ -71,7 +71,7 @@ class LibraryInstallerTest extends TestCase
$this->fs->removeDirectory($this->vendorDir); $this->fs->removeDirectory($this->vendorDir);
new LibraryInstaller($this->io, $this->composer); new LibraryInstaller($this->io, $this->composer);
$this->assertFileNotExists($this->vendorDir); $this->assertFileDoesNotExist($this->vendorDir);
} }
public function testInstallerCreationShouldNotCreateBinDirectory() public function testInstallerCreationShouldNotCreateBinDirectory()
@ -79,7 +79,7 @@ class LibraryInstallerTest extends TestCase
$this->fs->removeDirectory($this->binDir); $this->fs->removeDirectory($this->binDir);
new LibraryInstaller($this->io, $this->composer); new LibraryInstaller($this->io, $this->composer);
$this->assertFileNotExists($this->binDir); $this->assertFileDoesNotExist($this->binDir);
} }
public function testIsInstalled() public function testIsInstalled()

View File

@ -68,7 +68,7 @@ class ArchiveManagerTest extends ArchiverTest
$this->assertFileExists($target); $this->assertFileExists($target);
$tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package);
$this->assertFileNotExists($tmppath); $this->assertFileDoesNotExist($tmppath);
unlink($target); unlink($target);
} }
@ -90,7 +90,7 @@ class ArchiveManagerTest extends ArchiverTest
$this->assertFileExists($target); $this->assertFileExists($target);
$tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package); $tmppath = sys_get_temp_dir().'/composer_archiver/'.$this->manager->getPackageFilename($package);
$this->assertFileNotExists($tmppath); $this->assertFileDoesNotExist($tmppath);
unlink($target); unlink($target);
} }

View File

@ -35,7 +35,11 @@ class ErrorHandlerTest extends TestCase
*/ */
public function testErrorHandlerCaptureNotice() 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 = array('foo' => 'bar');
$array['baz']; $array['baz'];

View File

@ -168,7 +168,7 @@ class FilesystemTest extends TestCase
$fs = new Filesystem; $fs = new Filesystem;
$this->assertTrue($fs->removeDirectoryPhp($this->workingDir)); $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() public function testFileSize()
@ -247,7 +247,7 @@ class FilesystemTest extends TestCase
$fs = new Filesystem(); $fs = new Filesystem();
$result = $fs->unlink($symlinked); $result = $fs->unlink($symlinked);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFileNotExists($symlinked); $this->assertFileDoesNotExist($symlinked);
} }
/** /**
@ -279,8 +279,8 @@ class FilesystemTest extends TestCase
$result = $fs->removeDirectory($symlinkedTrailingSlash); $result = $fs->removeDirectory($symlinkedTrailingSlash);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFileNotExists($symlinkedTrailingSlash); $this->assertFileDoesNotExist($symlinkedTrailingSlash);
$this->assertFileNotExists($symlinked); $this->assertFileDoesNotExist($symlinked);
} }
public function testJunctions() public function testJunctions()

View File

@ -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'); $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->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']['verify_peer']);
$this->assertTrue($res['ssl']['SNI_enabled']); $this->assertTrue($res['ssl']['SNI_enabled']);
$this->assertEquals(7, $res['ssl']['verify_depth']); $this->assertEquals(7, $res['ssl']['verify_depth']);