From: William Desportes <williamdes@wdes.fr>
Date: Mon, 14 Apr 2025 16:46:13 +0200
Subject: Make the autoload and source path configurable

Origin: vendor
Forwarded: not-needed
---
 tests/bootstrap.php | 39 ++++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 3b6bef3..d34453c 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -3,20 +3,41 @@
 use Phing\Phing;
 
 defined('PHING_TEST_BASE') || define('PHING_TEST_BASE', __DIR__);
+$phingSource = getenv('PHING_SOURCE');
+
+if (! is_string($phingSource)) {
+    echo 'PHING_SOURCE is not set';
+    exit(1);
+}
+
+$phingSource = realpath(rtrim($phingSource, '/'));
+
+if (! is_dir($phingSource)) {
+    echo 'PHING_SOURCE is not a folder: ' . $phingSource;
+    exit(1);
+}
+
 set_include_path(
-    realpath(__DIR__ . '/../src') . PATH_SEPARATOR .
-    realpath(__DIR__ . '/src') . PATH_SEPARATOR .
-    get_include_path()  // trunk version of phing classes should take precedence
+    $phingSource . PATH_SEPARATOR . '/usr/share/php'
 );
 
-// Use composers autoload.php if available
-if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
-    require_once __DIR__ . '/../vendor/autoload.php';
-} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
-    require_once __DIR__ . '/../../../autoload.php';
+$phingAutoload = getenv('PHING_AUTOLOAD');
+
+if (! is_string($phingAutoload)) {
+    echo 'PHING_AUTOLOAD is not set';
+    exit(1);
 }
 
-Phing::setProperty('phing.home', realpath(__DIR__ . '/../'));
+$phingAutoload = realpath($phingAutoload);
+
+if (! is_file($phingAutoload)) {
+    echo 'PHING_AUTOLOAD is not a file: ' . $phingAutoload;
+    exit(1);
+}
+
+require_once $phingAutoload;
+
+Phing::setProperty('phing.home', $phingSource);
 Phing::startup();
 
 error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
