Skip to content

Commit 83a0211

Browse files
authored
test: Add a test for the min PHP version (#890)
The autoload modified by PHP-Scoper should be compatible with PHP 7.2.
1 parent cbef87b commit 83a0211

File tree

9 files changed

+91
-1
lines changed

9 files changed

+91
-1
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ jobs:
9999
composer:
100100
- 'composer:2.2'
101101
- 'composer'
102+
include:
103+
- e2e: 'e2e_039'
104+
php: '8.1'
105+
composer: 'composer:2.2'
102106

103107
steps:
104108
- name: Checkout

.makefile/e2e.file

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,32 @@ _e2e_038:
404404
@# To keep in sync with .github/workflows/e2e-tests.yaml#test-phpunit-scoping
405405
cd $(E2E_PHPUNIT_DIR); XDEBUG_MODE=coverage ant run-phar-specific-tests
406406

407+
.PHONY: e2e_039
408+
e2e_039: # Runs end-to-end tests for the fixture set e2e_037 — Codebase using scoped code
409+
e2e_039: $(PHP_SCOPER_PHAR_BIN)
410+
rm -rf fixtures/set039-min-php-version/vendor || true
411+
412+
composer --working-dir=fixtures/set039-min-php-version install
413+
414+
$(PHP_SCOPER_PHAR) add-prefix . \
415+
--working-dir=fixtures/set039-min-php-version \
416+
--output-dir=../../build/set039 \
417+
--force \
418+
--no-interaction \
419+
--stop-on-failure
420+
composer --working-dir=build/set039 dump-autoload
421+
422+
docker run \
423+
--interactive \
424+
--platform=linux/amd64 \
425+
--rm \
426+
--workdir=/opt/php-scoper \
427+
--volume="$$PWD":/opt/php-scoper \
428+
php:7.2-cli-alpine \
429+
php build/set039/index.php \
430+
> build/set039/output
431+
diff fixtures/set039-min-php-version/expected-output build/set039/output
432+
407433

408434
#
409435
# Rules from files

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ e2e: e2e_004 \
171171
e2e_035 \
172172
e2e_036 \
173173
e2e_037 \
174-
e2e_038
174+
e2e_038 \
175+
e2e_039
175176

176177
.PHONY: blackfire
177178
blackfire: ## Runs Blackfire profiling
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

fixtures/set039-min-php-version/composer.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OK
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App;
4+
5+
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
6+
? __DIR__.'/vendor/scoper-autoload.php'
7+
: __DIR__.'/vendor/autoload.php';
8+
9+
class Greeter {}
10+
11+
echo "OK\n";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Isolated\Symfony\Component\Finder\Finder;
6+
7+
// You can do your own things here, e.g. collecting symbols to expose dynamically
8+
// or files to exclude.
9+
// However beware that this file is executed by PHP-Scoper, hence if you are using
10+
// the PHAR it will be loaded by the PHAR. So it is highly recommended to avoid
11+
// to auto-load any code here: it can result in a conflict or even corrupt
12+
// the PHP-Scoper analysis.
13+
14+
// Example of collecting files to include in the scoped build but to not scope
15+
// leveraging the isolated finder.
16+
$excludedFiles = array_map(
17+
static fn (SplFileInfo $fileInfo) => $fileInfo->getPathName(),
18+
iterator_to_array(
19+
Finder::create()->files()->in(__DIR__),
20+
false,
21+
),
22+
);
23+
24+
return [
25+
'expose-classes' => ['App\Greeter'],
26+
];

tests/AutoReview/GAE2ETest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class GAE2ETest extends TestCase
2626
{
2727
private const IGNORED_E2E_TESTS = [
2828
'e2e_038',
29+
'e2e_039',
2930
];
3031

3132
public function test_github_actions_executes_all_the_e2e_tests(): void

0 commit comments

Comments
 (0)