From b345f0e65379456a3ce3aac1ed8f6b12bdcae12b Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 27 Aug 2024 09:44:42 +0200 Subject: [PATCH 1/5] Drop support for php 5 --- .github/workflows/runTests.yml | 11 ++++------- CHANGELOG.md | 7 ++++++- composer.json | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml index a833ef5..25a7212 100644 --- a/.github/workflows/runTests.yml +++ b/.github/workflows/runTests.yml @@ -16,11 +16,6 @@ jobs: fail-fast: false matrix: php-versions: - - '5.3' - - '5.4' - - '5.5' - - '5.6' - - '7.0' - '7.1' - '7.2' - '7.3' @@ -28,6 +23,8 @@ jobs: - '8.0' - '8.1' - '8.2' + - '8.3' + - '8.4' os: [ubuntu-latest, windows-latest, macOS-latest] steps: @@ -62,11 +59,11 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install dependencies for PHP < 8.0 - if: matrix.php-versions != '8.0' && matrix.php-versions != '8.1' && matrix.php-versions != '8.2' + if: matrix.php-versions != '8.0' && matrix.php-versions != '8.1' && matrix.php-versions != '8.2' && matrix.php-versions != '8.3' && matrix.php-versions != '8.4' run: composer install --prefer-dist --no-progress - name: Install PHPUnit 8 for PHP 8 - if: matrix.php-versions == '8.0' || matrix.php-versions == '8.1' || matrix.php-versions == '8.2' + if: matrix.php-versions == '8.0' || matrix.php-versions == '8.1' || matrix.php-versions == '8.2' || matrix.php-versions == '8.3' || matrix.php-versions == '8.4' run: | composer require --dev phpunit/phpunit:8.5.17 --ignore-platform-reqs git apply --reject --whitespace=fix src/test/patches/php8-return-types.diff diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ba58f..47cc0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -1.6.?? (2022-??-??) +1.6.12 (2024-??-??) +------------------- + +* Add support for PHP 8.2's `$content` property in `vfsStreamWrapper` + +1.6.11 (2022-07-26) ------------------- * Add support for PHP 8.2's `$content` property in `vfsStreamWrapper` diff --git a/composer.json b/composer.json index 2f5b8a9..d320d83 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "wiki": "https://github.com/bovigo/vfsStream/wiki" }, "require": { - "php": ">=5.3.0" + "php": ">=7.1.0" }, "require-dev": { "phpunit/phpunit": "^4.5|^5.0" From dafa5583632c272cf35473cb02007b86912d8719 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 27 Aug 2024 09:55:27 +0200 Subject: [PATCH 2/5] Attempt to fix phpunit run --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d320d83..932148c 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "^4.5|^5.0" + "phpunit/phpunit": "^7.5||^8.5||^9.6||^10.5||^11.3", + "yoast/phpunit-polyfills": "^1.1" }, "autoload": { "psr-0": { "org\\bovigo\\vfs\\": "src/main/php" } From a4a4e4ca07ba71bf17a76631e2c26986c6c0c72c Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 27 Aug 2024 10:09:36 +0200 Subject: [PATCH 3/5] Upgrade tests to run on newer phpunit --- .github/workflows/runTests.yml | 3 +- composer.json | 4 +- phpunit.xml.dist | 3 +- src/test/bootstrap.php | 79 +++++++++---------- src/test/patches/php8-return-types.diff | 21 ----- .../bovigo/vfs/DirectoryIterationTestCase.php | 4 +- .../php/org/bovigo/vfs/FilenameTestCase.php | 6 +- .../org/bovigo/vfs/PermissionsTestCase.php | 9 ++- src/test/php/org/bovigo/vfs/QuotaTestCase.php | 2 +- .../vfs/content/LargeFileContentTestCase.php | 2 +- .../StringBasedFileContentTestCase.php | 2 +- .../org/bovigo/vfs/vfsStreamBlockTestCase.php | 4 +- .../vfsStreamContainerIteratorTestCase.php | 4 +- .../vfsStreamDirectoryIssue134TestCase.php | 2 +- .../vfs/vfsStreamDirectoryIssue18TestCase.php | 2 +- .../bovigo/vfs/vfsStreamDirectoryTestCase.php | 6 +- .../bovigo/vfs/vfsStreamExLockTestCase.php | 2 +- .../org/bovigo/vfs/vfsStreamFileTestCase.php | 4 +- .../vfsStreamResolveIncludePathTestCase.php | 4 +- .../php/org/bovigo/vfs/vfsStreamTestCase.php | 8 +- .../org/bovigo/vfs/vfsStreamUmaskTestCase.php | 4 +- ...StreamWrapperAlreadyRegisteredTestCase.php | 6 +- .../vfs/vfsStreamWrapperBaseTestCase.php | 2 +- .../vfsStreamWrapperDirSeparatorTestCase.php | 2 +- .../vfs/vfsStreamWrapperDirTestCase.php | 11 ++- .../vfs/vfsStreamWrapperFileTimesTestCase.php | 2 +- .../vfs/vfsStreamWrapperFlockTestCase.php | 2 +- .../vfs/vfsStreamWrapperLargeFileTestCase.php | 2 +- .../vfs/vfsStreamWrapperQuotaTestCase.php | 2 +- .../vfs/vfsStreamWrapperSetOptionTestCase.php | 2 +- .../bovigo/vfs/vfsStreamWrapperTestCase.php | 22 +++--- .../vfsStreamWrapperUnregisterTestCase.php | 4 +- .../vfsStreamWrapperWithoutRootTestCase.php | 2 +- .../org/bovigo/vfs/vfsStreamZipTestCase.php | 2 +- .../vfsStreamAbstractVisitorTestCase.php | 4 +- .../visitor/vfsStreamPrintVisitorTestCase.php | 4 +- 36 files changed, 113 insertions(+), 131 deletions(-) delete mode 100644 src/test/patches/php8-return-types.diff diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml index 25a7212..0dc51cc 100644 --- a/.github/workflows/runTests.yml +++ b/.github/workflows/runTests.yml @@ -65,8 +65,7 @@ jobs: - name: Install PHPUnit 8 for PHP 8 if: matrix.php-versions == '8.0' || matrix.php-versions == '8.1' || matrix.php-versions == '8.2' || matrix.php-versions == '8.3' || matrix.php-versions == '8.4' run: | - composer require --dev phpunit/phpunit:8.5.17 --ignore-platform-reqs - git apply --reject --whitespace=fix src/test/patches/php8-return-types.diff + composer install --prefer-dist --no-progress - name: Run test suite run: composer run-script test -- --coverage-text diff --git a/composer.json b/composer.json index 932148c..f729a8d 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "^7.5||^8.5||^9.6||^10.5||^11.3", - "yoast/phpunit-polyfills": "^1.1" + "phpunit/phpunit": "^7.5||^8.5||^9.6", + "yoast/phpunit-polyfills": "^2.0" }, "autoload": { "psr-0": { "org\\bovigo\\vfs\\": "src/main/php" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e48588e..56057d7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" forceCoversAnnotation="false" mapTestClassNameToCoveredClassName="false" - printerClass="PHPUnit_TextUI_ResultPrinter" processIsolation="false" stopOnError="false" stopOnFailure="false" @@ -41,4 +40,4 @@ - \ No newline at end of file + diff --git a/src/test/bootstrap.php b/src/test/bootstrap.php index 8b1f889..3674591 100644 --- a/src/test/bootstrap.php +++ b/src/test/bootstrap.php @@ -12,34 +12,31 @@ class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error'); } -if (!class_exists("PHPUnit_Util_ErrorHandler")) -{ - class PHPUnit_Util_ErrorHandler { - public static function handleError($errno, $errstr, $errfile, $errline) - { - $errorHandler = new \PHPUnit\Util\ErrorHandler( - true, - true, - true, - true - ); - - return $errorHandler($errno, $errstr, $errfile, $errline); - } - } -} - -if (!class_exists("PHPUnit_TextUI_ResultPrinter")) -{ - class PHPUnit_TextUI_ResultPrinter extends \PHPUnit\TextUI\ResultPrinter {} -} - +//if (!class_exists("PHPUnit_Util_ErrorHandler")) +//{ +// class PHPUnit_Util_ErrorHandler { +// public static function handleError($errno, $errstr, $errfile, $errline) +// { +// $errorHandler = new \PHPUnit\Util\ErrorHandler( +// true, +// true, +// true, +// true +// ); +// +// return $errorHandler($errno, $errstr, $errfile, $errline); +// } +// } +//} /** * A modified version of PHPUnit's TestCase to rid ourselves of deprecation * warnings since we're using two different versions of PHPUnit in this branch * (PHPUnit 4 and 5). */ -class BC_PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase { +class BC_PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase { + + use \Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames; + public function bc_expectException($exception) { if (method_exists($this, 'expectException')) { @@ -64,21 +61,21 @@ public function bc_getMock($originalClassName, $methods = array(), array $argume } } -// The only deprecation warnings we need to ignore/handle are in PHP 7.4 so far -if (PHP_VERSION_ID >= 70400) { - function customErrorHandler($errno, $errstr, $errfile, $errline) { - // We know about this deprecation warning exists and it's already been - // fixed in the 2.x branch. For BC reasons in the 1.x branch, we'll - // ignore this warning to let tests pass. - if ($errno === E_DEPRECATED) { - if ($errstr === "Function ReflectionType::__toString() is deprecated") { - return true; - } - } - - // Any other error should be left up to PHPUnit to handle - return \PHPUnit_Util_ErrorHandler::handleError($errno, $errstr, $errfile, $errline); - } - - set_error_handler("customErrorHandler"); -} +//// The only deprecation warnings we need to ignore/handle are in PHP 7.4 so far +//if (PHP_VERSION_ID >= 70400) { +// function customErrorHandler($errno, $errstr, $errfile, $errline) { +// // We know about this deprecation warning exists and it's already been +// // fixed in the 2.x branch. For BC reasons in the 1.x branch, we'll +// // ignore this warning to let tests pass. +// if ($errno === E_DEPRECATED) { +// if ($errstr === "Function ReflectionType::__toString() is deprecated") { +// return true; +// } +// } +// +// // Any other error should be left up to PHPUnit to handle +// return \PHPUnit_Util_ErrorHandler::handleError($errno, $errstr, $errfile, $errline); +// } +// +// set_error_handler("customErrorHandler"); +//} diff --git a/src/test/patches/php8-return-types.diff b/src/test/patches/php8-return-types.diff deleted file mode 100644 index 040906d..0000000 --- a/src/test/patches/php8-return-types.diff +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/vendor/phpunit/phpunit/src/Framework/TestCase.php b/vendor/phpunit/phpunit/src/Framework/TestCase.php -index 1223ca0c8..b5725af4c 100644 ---- a/vendor/phpunit/phpunit/src/Framework/TestCase.php -+++ b/vendor/phpunit/phpunit/src/Framework/TestCase.php -@@ -475,14 +475,14 @@ public static function tearDownAfterClass(): void - /** - * This method is called before each test. - */ -- protected function setUp(): void -+ protected function setUp() - { - } - - /** - * This method is called after each test. - */ -- protected function tearDown(): void -+ protected function tearDown() - { - } - diff --git a/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php b/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php index 4f30b03..6fcdf2a 100644 --- a/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php +++ b/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php @@ -20,7 +20,7 @@ class DirectoryIterationTestCase extends vfsStreamWrapperBaseTestCase /** * clean up test environment */ - public function tearDown() + public function tearDown(): void { vfsStream::enableDotfiles(); } @@ -315,4 +315,4 @@ public function recursiveDirectoryIterationWithDotsDisabled() $pathes ); } -} \ No newline at end of file +} diff --git a/src/test/php/org/bovigo/vfs/FilenameTestCase.php b/src/test/php/org/bovigo/vfs/FilenameTestCase.php index 4b44130..678038f 100644 --- a/src/test/php/org/bovigo/vfs/FilenameTestCase.php +++ b/src/test/php/org/bovigo/vfs/FilenameTestCase.php @@ -23,7 +23,7 @@ class FilenameTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { vfsStream::setup('root'); $this->rootDir = vfsStream::url('root'); @@ -53,11 +53,11 @@ public function worksWithCorrectName() /** * @test - * @expectedException UnexpectedValueException - * @expectedExceptionMessage ailed to open dir */ public function doesNotWorkWithInvalidName() { + $this->expectException(\UnexpectedValueException::class); + $this->expectExceptionMessage('ailed to open dir'); $results = array(); $it = new \RecursiveDirectoryIterator($this->rootDir . '/lost found/'); foreach ($it as $f) { diff --git a/src/test/php/org/bovigo/vfs/PermissionsTestCase.php b/src/test/php/org/bovigo/vfs/PermissionsTestCase.php index e99a55a..185be7f 100644 --- a/src/test/php/org/bovigo/vfs/PermissionsTestCase.php +++ b/src/test/php/org/bovigo/vfs/PermissionsTestCase.php @@ -8,6 +8,8 @@ * @package org\bovigo\vfs */ namespace org\bovigo\vfs; +use PHPUnit\Framework\Error; + /** * Test for permissions related functionality. * @@ -23,7 +25,7 @@ class PermissionsTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setup() + public function setUp(): void { $structure = array('test_directory' => array('test.file' => '')); $this->root = vfsStream::setup('root', null, $structure); @@ -92,13 +94,14 @@ public function canNotChangeGroupWhenFileNotOwned() /** * @test * @group issue_107 - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionMessage Can not create new file in non-writable path root * @requires PHP 5.4 * @since 1.5.0 */ public function touchOnNonWriteableDirectoryTriggersError() { + $this->expectException(Error\Warning::class); + $this->expectExceptionMessage('Can not create new file in non-writable path root'); + $this->root->chmod(0555); touch($this->root->url() . '/touch.txt'); } diff --git a/src/test/php/org/bovigo/vfs/QuotaTestCase.php b/src/test/php/org/bovigo/vfs/QuotaTestCase.php index 8c0f5b2..b56afd9 100644 --- a/src/test/php/org/bovigo/vfs/QuotaTestCase.php +++ b/src/test/php/org/bovigo/vfs/QuotaTestCase.php @@ -25,7 +25,7 @@ class QuotaTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->quota = new Quota(10); } diff --git a/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php b/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php index c9015e1..203f598 100644 --- a/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php +++ b/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php @@ -26,7 +26,7 @@ class LargeFileContentTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->largeFileContent = new LargeFileContent(100); } diff --git a/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php b/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php index 137a092..75fc3f9 100644 --- a/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php +++ b/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php @@ -26,7 +26,7 @@ class StringBasedFileContentTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->stringBasedFileContent = new StringBasedFileContent('foobarbaz'); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php index cd8e1a4..40a8b59 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php @@ -20,7 +20,7 @@ class vfsStreamBlockTestCase extends \BC_PHPUnit_Framework_TestCase */ protected $block; - public function setUp() + public function setUp(): void { $this->block = new vfsStreamBlock('foo'); } @@ -73,10 +73,10 @@ public function addStructure() /** * tests that a blank name for a block device throws an exception * @test - * @expectedException org\bovigo\vfs\vfsStreamException */ public function createWithEmptyName() { + $this->expectException(vfsStreamException::class); $structure = array( 'topLevel' => array( 'thisIsAFile' => 'file contents', diff --git a/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php index 934e014..7698be0 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php @@ -35,7 +35,7 @@ class vfsStreamContainerIteratorTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->dir = new vfsStreamDirectory('foo'); $this->mockChild1 = $this->bc_getMock('org\\bovigo\\vfs\\vfsStreamContent'); @@ -53,7 +53,7 @@ public function setUp() /** * clean up test environment */ - public function tearDown() + public function tearDown(): void { vfsStream::enableDotfiles(); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue134TestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue134TestCase.php index c1c0dda..3e82589 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue134TestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue134TestCase.php @@ -22,7 +22,7 @@ class vfsStreamDirectoryIssue134TestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->rootDirectory = vfsStream::newDirectory('/'); $this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app')); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php index fdf45b2..1bf8661 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php @@ -25,7 +25,7 @@ class vfsStreamDirectoryIssue18TestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->rootDirectory = vfsStream::newDirectory('/'); $this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app')); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php index 19ed51b..68e1bee 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php @@ -23,7 +23,7 @@ class vfsStreamDirectoryTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->dir = new vfsStreamDirectory('foo'); } @@ -32,10 +32,10 @@ public function setUp() * assure that a directory seperator inside the name throws an exception * * @test - * @expectedException org\bovigo\vfs\vfsStreamException */ public function invalidCharacterInName() { + $this->expectException(vfsStreamException::class); $dir = new vfsStreamDirectory('foo/bar'); } @@ -72,10 +72,10 @@ public function rename() * renaming the directory to an invalid name throws a vfsStreamException * * @test - * @expectedException org\bovigo\vfs\vfsStreamException */ public function renameToInvalidNameThrowsvfsStreamException() { + $this->expectException(vfsStreamException::class); $this->dir->rename('foo/baz'); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php index 66ad14d..891ee1d 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php @@ -19,7 +19,7 @@ class vfsStreamExLockTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - protected function setUp() + public function setUp(): void { $root = vfsStream::setup(); vfsStream::newFile('testfile')->at($root); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php index 5b7ade6..537bcbe 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php @@ -23,7 +23,7 @@ class vfsStreamFileTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->file = new vfsStreamFile('foo'); } @@ -327,11 +327,11 @@ public function withContentAcceptsAnyFileContentInstance() /** * @test * @group issue_79 - * @expectedException \InvalidArgumentException * @since 1.3.0 */ public function withContentThrowsInvalidArgumentExceptionWhenContentIsNoStringAndNoFileContent() { + $this->expectException(\InvalidArgumentException::class); $this->file->withContent(313); } } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php index 74fb773..7f0130c 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php @@ -26,7 +26,7 @@ class vfsStreamResolveIncludePathTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->backupIncludePath = get_include_path(); vfsStream::setup(); @@ -37,7 +37,7 @@ public function setUp() /** * clean up test environment */ - public function tearDown() + public function tearDown(): void { set_include_path($this->backupIncludePath); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php index cc2bad7..38e1f0d 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php @@ -19,7 +19,7 @@ class vfsStreamTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { vfsStreamWrapper::register(); } @@ -387,11 +387,11 @@ public function createArraysAreTurnedIntoSubdirectoriesOfRoot() /** * @test * @group issue_20 - * @expectedException \InvalidArgumentException * @since 0.11.0 */ public function createThrowsExceptionIfNoBaseDirGivenAndNoRootSet() { + $this->expectException(\InvalidArgumentException::class); vfsStream::create(array('test' => array())); } @@ -566,11 +566,11 @@ public function inspectWithoutContentGivesRootToVisitor() /** * @test * @group issue_10 - * @expectedException \InvalidArgumentException * @since 0.10.0 */ public function inspectWithoutContentAndWithoutRootThrowsInvalidArgumentException() { + $this->expectException(\InvalidArgumentException::class); $mockVisitor = $this->bc_getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor'); $mockVisitor->expects($this->never()) ->method('visit'); @@ -592,11 +592,11 @@ protected function getFileSystemCopyDir() /** * @test * @group issue_4 - * @expectedException \InvalidArgumentException * @since 0.11.0 */ public function copyFromFileSystemThrowsExceptionIfNoBaseDirGivenAndNoRootSet() { + $this->expectException(\InvalidArgumentException::class); vfsStream::copyFromFileSystem($this->getFileSystemCopyDir()); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php index 62fc2e1..2747399 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php @@ -20,7 +20,7 @@ class vfsStreamUmaskTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { vfsStream::umask(0000); } @@ -28,7 +28,7 @@ public function setUp() /** * clean up test environment */ - public function tearDown() + public function tearDown(): void { vfsStream::umask(0000); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php index 279a2ce..786c3b8 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php @@ -33,7 +33,7 @@ class vfsStreamWrapperAlreadyRegisteredTestCase extends \BC_PHPUnit_Framework_Te /** * set up test environment */ - public function setUp() + public function setUp(): void { TestvfsStreamWrapper::unregister(); $mock = $this->bc_getMock('org\\bovigo\\vfs\\vfsStreamWrapper'); @@ -43,7 +43,7 @@ public function setUp() /** * clean up test environment */ - public function tearDown() + public function tearDown(): void { TestvfsStreamWrapper::unregister(); } @@ -53,10 +53,10 @@ public function tearDown() * registered for the vfs scheme should throw an exception * * @test - * @expectedException org\bovigo\vfs\vfsStreamException */ public function registerOverAnotherStreamWrapper() { + $this->expectException(vfsStreamException::class); vfsStreamWrapper::register(); } } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php index 4c12a45..c60806d 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php @@ -65,7 +65,7 @@ abstract class vfsStreamWrapperBaseTestCase extends \BC_PHPUnit_Framework_TestCa /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->fooURL = vfsStream::url('foo'); $this->barURL = vfsStream::url('foo/bar'); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php index 35fc0ce..f901043 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php @@ -26,7 +26,7 @@ class vfsStreamWrapperDirSeparatorTestCase extends \BC_PHPUnit_Framework_TestCas /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->root = vfsStream::setup(); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php index 5f840c4..bd61597 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php @@ -8,6 +8,8 @@ * @package org\bovigo\vfs */ namespace org\bovigo\vfs; +use PHPUnit\Framework\Error; + require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php'; /** * Test for org\bovigo\vfs\vfsStreamWrapper around mkdir(). @@ -214,11 +216,12 @@ public function mkDirShouldNotOverwriteExistingDirectories() /** * @test * @group issue_28 - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionMessage mkdir(): Path vfs://root/dir exists */ public function mkDirShouldNotOverwriteExistingDirectoriesAndTriggerE_USER_WARNING() { + $this->expectException(Error\Warning::class); + $this->expectExceptionMessage('mkdir(): Path vfs://root/dir exists'); + vfsStream::setup('root'); $dir = vfsStream::url('root/dir'); $this->assertTrue(mkdir($dir)); @@ -239,11 +242,11 @@ public function mkDirShouldNotOverwriteExistingFiles() /** * @test * @group issue_28 - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionMessage mkdir(): Path vfs://root/test.txt exists */ public function mkDirShouldNotOverwriteExistingFilesAndTriggerE_USER_WARNING() { + $this->expectException(Error\Warning::class); + $this->expectExceptionMessage('mkdir(): Path vfs://root/test.txt exists'); $root = vfsStream::setup('root'); vfsStream::newFile('test.txt')->at($root); $this->assertFalse(mkdir(vfsStream::url('root/test.txt'))); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php index cd3ea22..f58b6bc 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php @@ -37,7 +37,7 @@ class vfsStreamWrapperFileTimesTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { vfsStream::setup() ->lastModified(50) diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php index 3fb137f..114dd48 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php @@ -29,7 +29,7 @@ class vfsStreamWrapperFlockTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->root = vfsStream::setup(); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php index fb5d9fd..d6ae211 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php @@ -29,7 +29,7 @@ class vfsStreamWrapperLargeFileTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $root = vfsStream::setup(); $this->largeFile = vfsStream::newFile('large.txt') diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php index 9503190..574ab9f 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php @@ -25,7 +25,7 @@ class vfsStreamWrapperQuotaTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->root = vfsStream::setup(); vfsStream::setQuota(10); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php index ff2ab14..8f232b7 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php @@ -27,7 +27,7 @@ class vfsStreamWrapperSetOptionTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->root = vfsStream::setup(); vfsStream::newFile('foo.txt')->at($this->root); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php index f2b3234..b991963 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php @@ -8,6 +8,8 @@ * @package org\bovigo\vfs */ namespace org\bovigo\vfs; +use PHPUnit\Framework\Error; + require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php'; /** * Test for org\bovigo\vfs\vfsStreamWrapper. @@ -405,7 +407,7 @@ public function renameDirectory() $baz3URL = vfsStream::url('foo/baz3'); $this->assertTrue(rename($this->barURL, $baz3URL)); $this->assertFileExists($baz3URL); - $this->assertFileNotExists($this->barURL); + $this->assertFileDoesNotExist($this->barURL); } /** @@ -417,7 +419,7 @@ public function renameDirectoryWithDots() $baz3URL = vfsStream::url('foo/baz3'); $this->assertTrue(rename($this->barURL . '/.', $baz3URL)); $this->assertFileExists($baz3URL); - $this->assertFileNotExists($this->barURL); + $this->assertFileDoesNotExist($this->barURL); } /** @@ -431,7 +433,7 @@ public function renameDirectoryWithDotsInTarget() $baz3URL = vfsStream::url('foo/../baz3/.'); $this->assertTrue(rename($this->barURL . '/.', $baz3URL)); $this->assertFileExists($baz3URL); - $this->assertFileNotExists($this->barURL); + $this->assertFileDoesNotExist($this->barURL); } /** @@ -443,20 +445,20 @@ public function renameDirectoryOverwritingExistingFile() // move foo/bar to foo/baz2 $this->assertTrue(rename($this->barURL, $this->baz2URL)); $this->assertFileExists(vfsStream::url('foo/baz2/baz1')); - $this->assertFileNotExists($this->barURL); + $this->assertFileDoesNotExist($this->barURL); } /** * @test - * @expectedException PHPUnit_Framework_Error */ public function renameFileIntoFile() { + $this->expectException(Error\Warning::class); // foo/baz2 is a file, so it can not be turned into a directory $baz3URL = vfsStream::url('foo/baz2/baz3'); $this->assertTrue(rename($this->baz1URL, $baz3URL)); $this->assertFileExists($baz3URL); - $this->assertFileNotExists($this->baz1URL); + $this->assertFileDoesNotExist($this->baz1URL); } /** @@ -470,27 +472,27 @@ public function renameFileToDirectory() $this->assertTrue(rename($this->baz1URL, $baz3URL)); $this->assertFileExists($this->barURL); $this->assertFileExists($baz3URL); - $this->assertFileNotExists($this->baz1URL); + $this->assertFileDoesNotExist($this->baz1URL); } /** * assert that trying to rename from a non existing file trigger a warning * - * @expectedException PHPUnit_Framework_Error * @test */ public function renameOnSourceFileNotFound() { + $this->expectException(Error\Warning::class); rename(vfsStream::url('notfound'), $this->baz1URL); } /** * assert that trying to rename to a directory that is not found trigger a warning - * @expectedException PHPUnit_Framework_Error * @test */ public function renameOnDestinationDirectoryFileNotFound() { + $this->expectException(Error\Warning::class); rename($this->baz1URL, vfsStream::url('foo/notfound/file2')); } /** @@ -619,10 +621,10 @@ public function statReturnsFullDataForDirectoriesWithDot() /** * @test - * @expectedException PHPUnit_Framework_Error */ public function openFileWithoutDirectory() { + $this->expectException(Error\Warning::class); vfsStreamWrapper::register(); $this->assertFalse(file_get_contents(vfsStream::url('file.txt'))); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperUnregisterTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperUnregisterTestCase.php index 4e27685..01d1cfa 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperUnregisterTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperUnregisterTestCase.php @@ -31,11 +31,11 @@ public function unregisterRegisteredUrlWrapper() * Unregistering a third party wrapper for vfs:// fails. * * @test - * @expectedException org\bovigo\vfs\vfsStreamException * @runInSeparateProcess */ public function unregisterThirdPartyVfsScheme() { + $this->expectException(vfsStreamException::class); // Unregister possible registered URL wrapper. vfsStreamWrapper::unregister(); @@ -49,11 +49,11 @@ public function unregisterThirdPartyVfsScheme() * Unregistering when not in registered state will fail. * * @test - * @expectedException org\bovigo\vfs\vfsStreamException * @runInSeparateProcess */ public function unregisterWhenNotInRegisteredState() { + $this->expectException(vfsStreamException::class); vfsStreamWrapper::register(); stream_wrapper_unregister(vfsStream::SCHEME); vfsStreamWrapper::unregister(); diff --git a/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php index 8267a32..03c3d5b 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php @@ -16,7 +16,7 @@ class vfsStreamWrapperWithoutRootTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { vfsStreamWrapper::register(); } diff --git a/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php b/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php index 210642c..166186b 100644 --- a/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php +++ b/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php @@ -18,7 +18,7 @@ class vfsStreamZipTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { if (extension_loaded('zip') === false) { $this->markTestSkipped('No ext/zip installed, skipping test.'); diff --git a/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php b/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php index dfb3ed5..e1d1010 100644 --- a/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php +++ b/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php @@ -30,7 +30,7 @@ class vfsStreamAbstractVisitorTestCase extends \BC_PHPUnit_Framework_TestCase /** * set up test environment */ - public function setUp() + public function setUp(): void { $this->abstractVisitor = $this->bc_getMock('org\\bovigo\\vfs\\visitor\\vfsStreamAbstractVisitor', array('visitFile', 'visitDirectory') @@ -39,10 +39,10 @@ public function setUp() /** * @test - * @expectedException \InvalidArgumentException */ public function visitThrowsInvalidArgumentExceptionOnUnknownContentType() { + $this->expectException(\InvalidArgumentException::class); $mockContent = $this->bc_getMock('org\\bovigo\\vfs\\vfsStreamContent'); $mockContent->expects($this->any()) ->method('getType') diff --git a/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php b/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php index 294bd77..3f8b8c7 100644 --- a/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php +++ b/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php @@ -22,19 +22,19 @@ class vfsStreamPrintVisitorTestCase extends \BC_PHPUnit_Framework_TestCase { /** * @test - * @expectedException \InvalidArgumentException */ public function constructWithNonResourceThrowsInvalidArgumentException() { + $this->expectException(\InvalidArgumentException::class); new vfsStreamPrintVisitor('invalid'); } /** * @test - * @expectedException \InvalidArgumentException */ public function constructWithNonStreamResourceThrowsInvalidArgumentException() { + $this->expectException(\InvalidArgumentException::class); new vfsStreamPrintVisitor(xml_parser_create()); } From 2e39a43012d74d37c91a9124696a8ca57354ee02 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 27 Aug 2024 11:29:21 +0200 Subject: [PATCH 4/5] Disable coverage for php 7.1 --- .github/workflows/runTests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml index 0dc51cc..3d4f482 100644 --- a/.github/workflows/runTests.yml +++ b/.github/workflows/runTests.yml @@ -58,14 +58,14 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies for PHP < 8.0 - if: matrix.php-versions != '8.0' && matrix.php-versions != '8.1' && matrix.php-versions != '8.2' && matrix.php-versions != '8.3' && matrix.php-versions != '8.4' - run: composer install --prefer-dist --no-progress - - - name: Install PHPUnit 8 for PHP 8 - if: matrix.php-versions == '8.0' || matrix.php-versions == '8.1' || matrix.php-versions == '8.2' || matrix.php-versions == '8.3' || matrix.php-versions == '8.4' + - name: Install dependencies run: | composer install --prefer-dist --no-progress - name: Run test suite + if: matrix.php-versions == '7.1' + run: composer run-script test -- --no-coverage + + - name: Run test suite + if: matrix.php-versions > '7.1' run: composer run-script test -- --coverage-text From 001a27934ac1809c595e835f2eb82e80e8a96bfb Mon Sep 17 00:00:00 2001 From: Jaapio Date: Thu, 29 Aug 2024 13:52:17 +0200 Subject: [PATCH 5/5] Cleanup test bootstrap and changelog --- CHANGELOG.md | 2 +- src/test/bootstrap.php | 35 ----------------------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47cc0a9..c52bfda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ 1.6.12 (2024-??-??) ------------------- -* Add support for PHP 8.2's `$content` property in `vfsStreamWrapper` +* Drop php 5 and 7.0 support as new versions enforced a syntax change that is not compatible with the old versions. 1.6.11 (2022-07-26) ------------------- diff --git a/src/test/bootstrap.php b/src/test/bootstrap.php index 3674591..d4b3ba9 100644 --- a/src/test/bootstrap.php +++ b/src/test/bootstrap.php @@ -12,22 +12,6 @@ class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error'); } -//if (!class_exists("PHPUnit_Util_ErrorHandler")) -//{ -// class PHPUnit_Util_ErrorHandler { -// public static function handleError($errno, $errstr, $errfile, $errline) -// { -// $errorHandler = new \PHPUnit\Util\ErrorHandler( -// true, -// true, -// true, -// true -// ); -// -// return $errorHandler($errno, $errstr, $errfile, $errline); -// } -// } -//} /** * A modified version of PHPUnit's TestCase to rid ourselves of deprecation * warnings since we're using two different versions of PHPUnit in this branch @@ -60,22 +44,3 @@ public function bc_getMock($originalClassName, $methods = array(), array $argume return parent::getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget); } } - -//// The only deprecation warnings we need to ignore/handle are in PHP 7.4 so far -//if (PHP_VERSION_ID >= 70400) { -// function customErrorHandler($errno, $errstr, $errfile, $errline) { -// // We know about this deprecation warning exists and it's already been -// // fixed in the 2.x branch. For BC reasons in the 1.x branch, we'll -// // ignore this warning to let tests pass. -// if ($errno === E_DEPRECATED) { -// if ($errstr === "Function ReflectionType::__toString() is deprecated") { -// return true; -// } -// } -// -// // Any other error should be left up to PHPUnit to handle -// return \PHPUnit_Util_ErrorHandler::handleError($errno, $errstr, $errfile, $errline); -// } -// -// set_error_handler("customErrorHandler"); -//}