From c021e380d60eaf35b40a2f5becd92b8b32fbeee5 Mon Sep 17 00:00:00 2001 From: Robert O'Rourke Date: Fri, 27 Nov 2020 17:24:00 +0000 Subject: [PATCH] Apply patches on initial install/update The patches to get PHPUnit working are causing problems for other projects that use both `cweagans/composer-patch-installers` and `predis/predis` along with PHPUnit. This change moves the patch application to a simple PHP script run on the `post-update-cmd` composer event and removes the dependency on the patch installers package. --- composer.json | 18 ++++-------------- tests/apply-patches.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 tests/apply-patches.php diff --git a/composer.json b/composer.json index 4d273062..bde0b545 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,7 @@ "php": ">=5.3.9" }, "require-dev": { - "phpunit/phpunit": "~4.8", - "cweagans/composer-patches": "^1.6" + "phpunit/phpunit": "~4.8" }, "suggest": { "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol", @@ -43,16 +42,7 @@ "Predis\\": "src/" } }, - "extra": { - "composer-exit-on-patch-failure": true, - "patches": { - "phpunit/phpunit-mock-objects": { - "Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch" - }, - "phpunit/phpunit": { - "Fix PHP 7 compatibility": "./tests/phpunit_php7.patch", - "Fix PHP 8 compatibility": "./tests/phpunit_php8.patch" - } - } - } + "scripts": { + "post-update-cmd": "@php -f tests/apply-patches.php" + } } diff --git a/tests/apply-patches.php b/tests/apply-patches.php new file mode 100644 index 00000000..7294ab8d --- /dev/null +++ b/tests/apply-patches.php @@ -0,0 +1,15 @@ + 'phpunit/phpunit-mock-objects', + 'phpunit_php7.patch' => 'phpunit/phpunit', + 'phpunit_php8.patch' => 'phpunit/phpunit', +]; + +foreach ($patches as $patch => $package) { + chdir(__DIR__.'/../vendor/'.$package); + passthru(sprintf('patch -p1 -f < ../../../tests/%s', $patch)); +}