diff --git a/.makefile/e2e.file b/.makefile/e2e.file index a19531a4..d6f5e7db 100644 --- a/.makefile/e2e.file +++ b/.makefile/e2e.file @@ -431,6 +431,24 @@ e2e_039: $(PHP_SCOPER_PHAR_BIN) > build/set039/output || true diff fixtures/set039-min-php-version/expected-output build/set039/output +.PHONY: e2e_040 +e2e_040: # Runs end-to-end tests for the fixture set e2e_040 — Codebase using a polyfill +e2e_040: $(PHP_SCOPER_PHAR_BIN) + rm -rf fixtures/set040-polyfills/vendor || true + composer --working-dir=fixtures/set040-polyfills dump-autoload + + $(PHP_SCOPER_PHAR) add-prefix . \ + --working-dir=fixtures/set040-polyfills \ + --output-dir=../../build/set040 \ + --force \ + --no-interaction \ + --stop-on-failure + composer --working-dir=build/set040 dump-autoload + + php build/set040/index.php > build/set040/output || true + + diff fixtures/set040-polyfills/expected-output build/set040/output + # # Rules from files diff --git a/fixtures/set040-polyfills/bootstrap.php b/fixtures/set040-polyfills/bootstrap.php new file mode 100644 index 00000000..d2ef0fb5 --- /dev/null +++ b/fixtures/set040-polyfills/bootstrap.php @@ -0,0 +1,15 @@ += 200_000) { + return; +} + +if (!defined('NEW_PHP20_CONSTANT')) { + define('NEW_PHP20_CONSTANT', 42); +} + +if (!function_exists('new_php20_function')) { + function new_php20_function(bool $echo = false): void { Php20::new_php20_function($echo); } +} diff --git a/fixtures/set040-polyfills/composer.json b/fixtures/set040-polyfills/composer.json new file mode 100644 index 00000000..674008b2 --- /dev/null +++ b/fixtures/set040-polyfills/composer.json @@ -0,0 +1,11 @@ +{ + "bin": "index.php", + "autoload": { + "files": ["bootstrap.php"], + "classmap": ["stubs"], + "psr-4": { + "Set040\\Polyfill\\": "src/", + "Set040\\": "src/" + } + } +} diff --git a/fixtures/set040-polyfills/composer.lock b/fixtures/set040-polyfills/composer.lock new file mode 100644 index 00000000..ba6fe47d --- /dev/null +++ b/fixtures/set040-polyfills/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "d751713988987e9331980363e24189ce", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/fixtures/set040-polyfills/expected-output b/fixtures/set040-polyfills/expected-output new file mode 100644 index 00000000..d5c32f4a --- /dev/null +++ b/fixtures/set040-polyfills/expected-output @@ -0,0 +1 @@ +OK. diff --git a/fixtures/set040-polyfills/index.php b/fixtures/set040-polyfills/index.php new file mode 100644 index 00000000..69df1326 --- /dev/null +++ b/fixtures/set040-polyfills/index.php @@ -0,0 +1,27 @@ + [ + 'NewPhp20Interface', + 'NewPhp20Class', + ], + 'exclude-functions' => [ + 'new_php20_function', + ], + 'exclude-constants' => [ + 'NEW_PHP20_CONSTANT', + ], +]; diff --git a/fixtures/set040-polyfills/src/Php20.php b/fixtures/set040-polyfills/src/Php20.php new file mode 100644 index 00000000..fc794e0d --- /dev/null +++ b/fixtures/set040-polyfills/src/Php20.php @@ -0,0 +1,17 @@ +