diff --git a/Classes/Core/Functional/FunctionalTestCase.php b/Classes/Core/Functional/FunctionalTestCase.php index 390fa4ce..1dbec1f4 100644 --- a/Classes/Core/Functional/FunctionalTestCase.php +++ b/Classes/Core/Functional/FunctionalTestCase.php @@ -1005,6 +1005,7 @@ private function retrieveFrontendSubRequestResult( $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = $request->getUri()->getHost() ?: 'localhost'; + $outputBufferingLevel = ob_get_level(); $container = Bootstrap::init(ClassLoadingInformation::getClassLoader()); /** @var InternalRequest $serverRequest */ @@ -1050,8 +1051,12 @@ private function retrieveFrontendSubRequestResult( $frontendApplication = $container->get(Application::class); $response = $frontendApplication->handle($serverRequest); } finally { - // Somewhere an ob_start() is called in frontend that is not cleaned. Work around that for now. - ob_end_clean(); + // TYPO3 v14 opens an implicit output buffer in Bootstrap::init(), TYPO3 v15 + // does not. Frontend or extension code may leave further buffers open. Drop + // everything opened by the sub request, but never phpunit's own buffer. + while (ob_get_level() > $outputBufferingLevel) { + ob_end_clean(); + } FrameworkState::pop(); } return $response; diff --git a/Classes/Core/Testbase.php b/Classes/Core/Testbase.php index 010b61a7..6316e94e 100644 --- a/Classes/Core/Testbase.php +++ b/Classes/Core/Testbase.php @@ -754,10 +754,15 @@ public function setUpBasicTypo3Bootstrap(string $instancePath): ContainerInterfa $classLoader = require $this->getPackagesPath() . '/autoload.php'; SystemEnvironmentBuilder::run(0, SystemEnvironmentBuilder::REQUESTTYPE_CLI, false); + $outputBufferingLevel = ob_get_level(); $container = Bootstrap::init($classLoader); // Make sure output is not buffered, so command-line output can take place and - // phpunit does not whine about changed output bufferings in tests. - ob_end_clean(); + // phpunit does not whine about changed output bufferings in tests. TYPO3 v14 + // opens an implicit output buffer in Bootstrap::init(), TYPO3 v15 does not. + // Only drop buffers opened by the bootstrap, never phpunit's own one. + while (ob_get_level() > $outputBufferingLevel) { + ob_end_clean(); + } $this->dumpClassLoadingInformation();