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

[PhpUnitBridge] Fix some errors when using serialized deprecations #33820

Merged
merged 1 commit into from Feb 4, 2020

Conversation

greg0ire
Copy link
Contributor

@greg0ire greg0ire commented Oct 2, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

This PR attempts to fix conflicts that arose in #31478

Creating as a draft for now as I think having separate test methods no longer make sense (isSelf() and isIndirect() have been replaced with getType()). @l-vo please review and confirm I did not loose anything valuable from your original contribution.

@nicolas-grekas nicolas-grekas added this to the 4.3 milestone Oct 3, 2019
@greg0ire greg0ire marked this pull request as ready for review October 14, 2019 20:15
@greg0ire
Copy link
Contributor Author

I just renamed test methods that were tied to methods that no longer exists (isSelf(), isIndirect()). I think we'll have to do without a review from @l-vo

@l-vo
Copy link
Contributor

l-vo commented Oct 14, 2019

@greg0ire Excuse me, I'm currently running out of time and I have to get back into the context. But I'm going to look at this as soon as I can 😊

@l-vo
Copy link
Contributor

l-vo commented Oct 20, 2019

I reviewed and tested the changes, it looks good to me. Although there is a problem, the tests don't pass. The changes on the type "self" determination makes the type "self" difficult to test.

public function providerGetTypeDetectsSelf(): array
{
return [
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', ''],
Copy link
Contributor

@l-vo l-vo Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass anymore. A way to test it:

foreach (get_declared_classes() as $class) {
            if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
                $r = new \ReflectionClass($class);
                $v = \dirname(\dirname($r->getFileName()));
                if (file_exists($v.'/composer/installed.json')) {
                    $loader = require $v.'/autoload.php';
                    $reflection = new \ReflectionClass($loader);
                    $prop = $reflection->getProperty('prefixDirsPsr4');
                    $prop->setAccessible(true);
                    $currentValue = $prop->getValue($loader);
                    $currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];
                    $prop->setValue($loader, $currentValue);
                }
            }
        }

return [
            'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
            //...
];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot say I understand but I applied this change 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just change composer loader psr4 paths which are used to determine "self" type :)

'',
],
'serialized_trace_with_not_from_vendors_triggering_file' => [
Deprecation::TYPE_SELF,
Copy link
Contributor

@l-vo l-vo Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum it will depend from where tests are launched. I think we can remove this data provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', ''],
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
'serialized_trace_without_triggering_file' => [
Deprecation::TYPE_SELF,
Copy link
Contributor

@l-vo l-vo Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will depend from where tests are launched. I think we can remove this data provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@greg0ire
Copy link
Contributor Author

greg0ire commented Oct 24, 2019

@l-vo I applied your suggestions, please review again :)
Note that the patch from fabbot should not be applied as code in this particular component should still be compatible with php 5.5.9

Copy link
Contributor

@l-vo l-vo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@nicolas-grekas nicolas-grekas modified the milestones: 4.3, 4.4 Feb 1, 2020
@nicolas-grekas nicolas-grekas changed the title [PHPUnit Bridge] Carry #31478 [PhpUnitBridge] Fix some errors when using serialized deprecations Feb 4, 2020
@nicolas-grekas
Copy link
Member

Thank you @greg0ire.

nicolas-grekas added a commit that referenced this pull request Feb 4, 2020
…ecations (l-vo)

This PR was submitted for the 4.3 branch but it was squashed and merged into the 4.4 branch instead.

Discussion
----------

[PhpUnitBridge] Fix some errors when using serialized deprecations

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

This PR attempts to fix conflicts that arose in #31478

Creating as a draft for now as I think having separate test methods no longer make sense (`isSelf()` and `isIndirect()` have been replaced with `getType()`). @l-vo please review and confirm I did not loose anything valuable from your original contribution.

Commits
-------

056d598 [PhpUnitBridge] Fix some errors when using serialized deprecations
@nicolas-grekas nicolas-grekas merged commit 056d598 into symfony:4.4 Feb 4, 2020
@greg0ire greg0ire deleted the carry-31478 branch February 4, 2020 16:49
greg0ire added a commit to greg0ire/symfony that referenced this pull request Feb 5, 2020
I failed to apply perfectly this comment:
symfony#33820 (comment)
It should fix one failing test in the bridge.
greg0ire added a commit to greg0ire/symfony that referenced this pull request Feb 5, 2020
I failed to apply this comment perfectly:
symfony#33820 (comment)
It should fix one failing test in the bridge.
nicolas-grekas added a commit that referenced this pull request Feb 5, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[PHPunit bridge] Provide current file as file path

I failed to apply perfectly this comment:
#33820 (comment)
It should fix one failing test in the bridge.

| Q             | A
| ------------- | ---
| Branch?       |4.4
| Bug fix?      | not for the end user
| New feature?  | no
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

d5302cb Provide current file as file path
@fabpot fabpot mentioned this pull request Feb 29, 2020
@fabpot fabpot mentioned this pull request Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants