-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Make it easy for Drupal to use the PHPUnit bridge #24685
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
Conversation
@@ -342,8 +342,9 @@ public function request($method, $uri, array $parameters = array(), array $files | |||
protected function doRequestInProcess($request) | |||
{ | |||
$deprecationsFile = tempnam(sys_get_temp_dir(), 'deprec'); | |||
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$deprecationsFile); | |||
$process = new PhpProcess($this->getScript($request), null, null); | |||
$environment = getenv(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work before PHP 7.1
but I don't get what it changes in fact, so maybe it's not required at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this was trying to do was only set SYMFONY_DEPRECATIONS_SERIALIZE in the sub process so we didn't have to unset it after making the request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just relying on the feature of the Process component inheriting the env variables ?
I'm not sure I understand the technical purpose of this PR :) |
The technical purpose of this PR is to make PHPUnit Bridge's bootstrap.php not rely on assumptions about the environment. The problem is that we're doing
in our test bootstrap - so the assumption made by |
@@ -12,11 +12,9 @@ | |||
use Doctrine\Common\Annotations\AnnotationRegistry; | |||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; | |||
|
|||
// Detect if we're loaded by an actual run of phpunit | |||
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing this is broken. The logic will now register the bridge error handler even when the bootstrap.php file was not loaded during a composer run but during a normal usage of the app using the composer autoloader.
@alexpott are you actually defining |
@stof nope we're not defining when not running PHPUnit - we define it when running PHPUnit and inside an isolated test. This is because in PHPUnit's src/Util/PHP/Template/TestCaseMethod.tpl.dist it does
which needs to be able to autoload |
145bcd1
to
be56b35
Compare
I've updated the PR to only remove the check against PHPUNIT_COMPOSER_INSTALL since this constant is necessary for PHPUnit isolated tests where you are using a custom configuration file. I've tested this approach with Drupal and it works great. I've also tested Symfony locally with 5.5, 5.6 and 7.1 and it passes. |
I'm just testing this with Drupal and I've found something more odd going on. Still investigating. :( |
Thank you @alexpott. |
* 3.3: Revert "minor #24685 Make it easy for Drupal to use the PHPUnit bridge (alexpott)"
* 3.4: Revert "minor #24685 Make it easy for Drupal to use the PHPUnit bridge (alexpott)"
Reverted as it breaks something on our CI.
This can be reproduced locally by applying this patch: --- a/src/Symfony/Component/Process/Tests/ProcessTest.php
+++ b/src/Symfony/Component/Process/Tests/ProcessTest.php
@@ -1583,7 +1583,7 @@ EOTXT;
try {
$process->setEnhanceSigchildCompatibility(false);
$process->getExitCode();
- $this->fail('ENHANCE_SIGCHLD must be used together with a sigchild-enabled PHP.');
+ // $this->fail('ENHANCE_SIGCHLD must be used together with a sigchild-enabled PHP.');
} catch (RuntimeException $e) {
$this->assertSame('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.', $e->getMessage());
if ($enhance) { then running |
Drupal doesn't use src/Symfony/Bridge/PhpUnit/bin/simple-phpunit but would like to use the deprecation collection features of src/Symfony/Bridge/PhpUnit. The checks in src/Symfony/Bridge/PhpUnit/bootstrap.php mean that this is difficult because they rely on simple-phpunit - but I'm not sure that that is necessary.