Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-extensions CLI option only prevents extension PHARs from being loaded #5073

Closed
wickedOne opened this issue Oct 8, 2022 · 3 comments
Closed
Assignees
Labels
feature/test-runner CLI test runner type/bug Something is broken version/9 Something affects PHPUnit 9 version/10 Something affects PHPUnit 10

Comments

@wickedOne
Copy link

wickedOne commented Oct 8, 2022

Q A
PHPUnit version 9.5.25
PHP version 8.1
Installation Method Composer

Summary

the --no-extensions cli option does not apply to the <extension> element configured in the phpunit.xml

Current behavior

while passing the --no-extensions cli option, extensions configured in the extension element of phpunit.xml are loaded when running phpunit.

i'm not sure whether this is intended behaviour or an oversight tho (happens here)

$loadPharExtensions = true;
if ($cliConfiguration->hasNoExtensions() && $cliConfiguration->noExtensions()) {
$loadPharExtensions = false;
}
$pharExtensionDirectory = null;
if ($xmlConfiguration->phpunit()->hasExtensionsDirectory()) {
$pharExtensionDirectory = $xmlConfiguration->phpunit()->extensionsDirectory();
}
$extensionBootstrappers = [];
foreach ($xmlConfiguration->extensions() as $extension) {
$extensionBootstrappers[] = [
'className' => $extension->className(),
'parameters' => $extension->parameters(),
];
}

How to reproduce

minimal, self-contained test case to reproduce can be found over here

Expected behavior

the extensions configured in the extension element are not loaded like the ones from the pharDirectory

@wickedOne wickedOne added the type/bug Something is broken label Oct 8, 2022
@sebastianbergmann sebastianbergmann added version/9 Something affects PHPUnit 9 and removed version/9 Something affects PHPUnit 9 labels Feb 3, 2023
@sebastianbergmann sebastianbergmann changed the title --no-extensions cli option does not apply to the <extension> element --no-extensions CLI option only prevents extension PHARs from being loaded Feb 3, 2023
@sebastianbergmann sebastianbergmann self-assigned this Feb 3, 2023
@sebastianbergmann sebastianbergmann added feature/test-runner CLI test runner version/9 Something affects PHPUnit 9 version/10 Something affects PHPUnit 10 labels Feb 3, 2023
@wickedOne
Copy link
Author

thank you @sebastianbergmann !

@nightio
Copy link

nightio commented Jan 8, 2024

@sebastianbergmann It's not working on version 9.x (at least) as it still seems to have the same issue. Upon checking the code, I noticed that the $this->arguments variable used isn't defined. There is no $this->arguments variable, only $arguments. Please refer to this link for more details:

if (!isset($this->arguments['noExtensions'])) {

I tried fixing it locally, and when I replaced the undefined variable with $arguments, it worked correctly under both scenarios: when the option is provided in the CLI - the extensions are not loaded. Conversely, if the option is not provided, the extensions are loaded.

Could you take a look and possibly make this fix?

@sebastianbergmann
Copy link
Owner

Could you take a look and possibly make this fix?

Please open a new issue, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/bug Something is broken version/9 Something affects PHPUnit 9 version/10 Something affects PHPUnit 10
Projects
None yet
Development

No branches or pull requests

3 participants