diff --git a/.github/ci/files/bin/console b/.github/ci/files/bin/console index b37ac8fb..c52f9161 100644 --- a/.github/ci/files/bin/console +++ b/.github/ci/files/bin/console @@ -15,32 +15,32 @@ ob_get_clean(); -if (file_exists($a = getcwd() . '/vendor/autoload.php')) { +if (file_exists($a = getcwd() . '/vendor/autoload_runtime.php')) { include $a; -} elseif (file_exists($a = __DIR__ . '/../../../../vendor/autoload.php')) { +} elseif (file_exists($a = __DIR__ . '/../../../../vendor/autoload_runtime.php')) { include $a; -} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) { +} elseif (file_exists($a = __DIR__ . '/../vendor/autoload_runtime.php')) { include $a; } else { fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL); exit(1); } -\Pimcore\Bootstrap::setProjectRoot(); +return function (array $context) { + define('PIMCORE_CONSOLE', true); -define('PIMCORE_CONSOLE', true); + $input = new \Symfony\Component\Console\Input\ArgvInput(); + if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); + } + if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); + } -$input = new \Symfony\Component\Console\Input\ArgvInput(); -if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -/** @var \Pimcore\Kernel $kernel */ -$kernel = \Pimcore\Bootstrap::startupCli(); -$application = new \Pimcore\Console\Application($kernel); -$application->run(); + /** @var \Pimcore\Kernel $kernel */ + $kernel = \Pimcore\Bootstrap::startupCli(); + $application = new \Pimcore\Console\Application($kernel); + $application->run(); + return $application; +}; diff --git a/.github/ci/files/public/index_test.php b/.github/ci/files/public/index_test.php index c4daad55..4a4adba6 100644 --- a/.github/ci/files/public/index_test.php +++ b/.github/ci/files/public/index_test.php @@ -15,27 +15,28 @@ use Pimcore\Tool; use Symfony\Component\HttpFoundation\Request; -include __DIR__ . "/../vendor/autoload.php"; +include __DIR__ . "/../vendor/autoload_runtime.php"; -define('PIMCORE_PROJECT_ROOT', __DIR__ . '/..'); -define('APP_ENV', 'test'); +return function (array $context) { + define('PIMCORE_PROJECT_ROOT', __DIR__ . '/..'); + define('APP_ENV', 'test'); -\Pimcore\Bootstrap::setProjectRoot(); -\Pimcore\Bootstrap::bootstrap(); - -$request = Request::createFromGlobals(); + $request = Request::createFromGlobals(); // set current request as property on tool as there's no // request stack available yet -Tool::setCurrentRequest($request); + Tool::setCurrentRequest($request); -/** @var \Pimcore\Kernel $kernel */ -$kernel = \Pimcore\Bootstrap::kernel(); + \Pimcore\Bootstrap::bootstrap(); + /** @var \Pimcore\Kernel $kernel */ + $kernel = \Pimcore\Bootstrap::kernel(); // reset current request - will be read from request stack from now on -Tool::setCurrentRequest(null); + Tool::setCurrentRequest(null); -$response = $kernel->handle($request); -$response->send(); + $response = $kernel->handle($request); + $response->send(); -$kernel->terminate($request, $response); + $kernel->terminate($request, $response); + return $kernel; +}; diff --git a/composer.json b/composer.json index c21b32ce..4e813ef2 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,9 @@ "preferred-install": { "pimcore/pimcore": "source", "*": "dist" + }, + "allow-plugins": { + "symfony/runtime": true } }, "prefer-stable": true, @@ -26,7 +29,8 @@ "codeception/phpunit-wrapper": "^9", "codeception/module-asserts": "^2", "codeception/module-symfony": "^1.6.0 || ^3.1.0", - "symfony/dotenv": "^6.2 || ^5.4.21" + "symfony/dotenv": "^6.2 || ^5.4.21", + "symfony/runtime": "^6.4 || ^5.4" }, "suggest": { "pimcore/admin-ui-classic-bundle": "Required for Pimcore 11" diff --git a/tests/Service/OutputCacheServiceTest.php b/tests/Service/OutputCacheServiceTest.php index 8cf296c5..9ec026a9 100644 --- a/tests/Service/OutputCacheServiceTest.php +++ b/tests/Service/OutputCacheServiceTest.php @@ -156,12 +156,12 @@ public function testIgnoreCacheWhenRequestParameterIsPassed() $response = new JsonResponse(['data' => 123]); $this->sut->method('loadFromCache')->willReturn($response); $this->request->query->set('pimcore_nocache', 'true'); - \Pimcore::inDebugMode(true); // Act $cacheItem = $this->sut->load($this->request); // Assert + $this->assertEquals(true, \Pimcore::inDebugMode()); $this->assertEquals(null, $cacheItem); } } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index fed1e7c9..445cec3a 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -3,14 +3,14 @@ use Pimcore\Tests\Support\Util\Autoloader; -if (file_exists(__DIR__ . '/../vendor/autoload.php')) { - include __DIR__ . '/../vendor/autoload.php'; +if (file_exists(__DIR__ . '/../vendor/autoload_runtime.php')) { + include __DIR__ . '/../vendor/autoload_runtime.php'; $pimcoreTestDir = __DIR__ . '/../vendor/pimcore/pimcore/tests'; -} elseif (file_exists(__DIR__ . '/../../../../vendor/autoload.php')) { - include __DIR__ . '/../../../../vendor/autoload.php'; +} elseif (file_exists(__DIR__ . '/../../../../vendor/autoload_runtime.php')) { + include __DIR__ . '/../../../../vendor/autoload_runtime.php'; $pimcoreTestDir = __DIR__ . '/../../../../vendor/pimcore/pimcore/tests'; -} elseif (getenv('PIMCORE_PROJECT_ROOT') != '' && file_exists(getenv('PIMCORE_PROJECT_ROOT') . '/vendor/autoload.php')) { - include getenv('PIMCORE_PROJECT_ROOT') . '/vendor/autoload.php'; +} elseif (getenv('PIMCORE_PROJECT_ROOT') != '' && file_exists(getenv('PIMCORE_PROJECT_ROOT') . '/vendor/autoload_runtime.php')) { + include getenv('PIMCORE_PROJECT_ROOT') . '/vendor/autoload_runtime.php'; $pimcoreTestDir = getenv('PIMCORE_PROJECT_ROOT') . '/vendor/pimcore/pimcore/tests'; } elseif (getenv('PIMCORE_PROJECT_ROOT') != '') { throw new \Exception('Invalid Pimcore project root "' . getenv('PIMCORE_PROJECT_ROOT') . '"'); @@ -27,24 +27,28 @@ include $pimcoreTestsSupportDir . '/Util/Autoloader.php'; -\Pimcore\Bootstrap::setProjectRoot(); -\Pimcore\Bootstrap::bootstrap(); +return function (array $context) { -//error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING); + \Pimcore\Bootstrap::setProjectRoot(); + \Pimcore\Bootstrap::bootstrap(); -Autoloader::addNamespace('Pimcore\Tests', $pimcoreTestsSupportDir); //Pimcore 10 BC layer -Autoloader::addNamespace('Pimcore\Tests\Support', $pimcoreTestsSupportDir); -Autoloader::addNamespace('Pimcore\Model\DataObject', PIMCORE_CLASS_DIRECTORY . '/DataObject'); -Autoloader::addNamespace('DataHubBundle\Tests', __DIR__); -Autoloader::addNamespace('DataHubBundle\Tests', __DIR__ . '/_support'); + //error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING); + Autoloader::addNamespace('Pimcore\Tests', $pimcoreTestsSupportDir); //Pimcore 10 BC layer + Autoloader::addNamespace('Pimcore\Tests\Support', $pimcoreTestsSupportDir); + Autoloader::addNamespace('Pimcore\Model\DataObject', PIMCORE_CLASS_DIRECTORY . '/DataObject'); + Autoloader::addNamespace('DataHubBundle\Tests', __DIR__); + Autoloader::addNamespace('DataHubBundle\Tests', __DIR__ . '/_support'); -echo __DIR__ . '/_support'; -if (!defined('TESTS_PATH')) { - define('TESTS_PATH', __DIR__); -} + echo __DIR__ . '/_support'; -if (!defined('PIMCORE_TEST')) { - define('PIMCORE_TEST', true); -} + if (!defined('TESTS_PATH')) { + define('TESTS_PATH', __DIR__); + } + + if (!defined('PIMCORE_TEST')) { + define('PIMCORE_TEST', true); + } + +};