diff --git a/.github/ci/files/bin/console b/.github/ci/files/bin/console index b37ac8fb..3afd8d56 100644 --- a/.github/ci/files/bin/console +++ b/.github/ci/files/bin/console @@ -13,34 +13,35 @@ * @license http://www.pimcore.org/license GPLv3 and PEL */ +use Symfony\Component\Console\Input\InputInterface; + 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(); - -define('PIMCORE_CONSOLE', true); +return function (InputInterface $input) { + define('PIMCORE_CONSOLE', true); + if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); + } -$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'); -} + 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..16aea770 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->assertTrue(\Pimcore::inDebugMode()); $this->assertEquals(null, $cacheItem); } } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index fed1e7c9..f7d5cd75 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -2,15 +2,16 @@ use Pimcore\Tests\Support\Util\Autoloader; +define('PIMCORE_TEST', true); -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') . '"'); @@ -18,6 +19,10 @@ throw new \Exception('Unknown configuration! Pimcore project root not found, please set env variable PIMCORE_PROJECT_ROOT.'); } +$_SERVER['APP_ENV'] = 'test'; +$_SERVER['APP_DEBUG'] = true; + + $pimcoreTestsSupportDir = $pimcoreTestDir . '/Support'; //Pimcore 10 BC layer