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

[Phpunit] AssertEqualsToSameRector fails if markTest* exists in function #5799

Closed
Bl00D4NGEL opened this issue Mar 8, 2021 · 4 comments
Closed
Labels

Comments

@Bl00D4NGEL
Copy link
Contributor

Bug Report

Subject Details
Rector version Rector 0.9.29
Installed as prefixed Rector

It seems that the AssertPropertyExistsRector fails if a markTestIncomplete or markTestSkipped is present in the (test) function it tries to refactor. The error is Uncaught Error: Call to a member function getType() on null in <path-to-vendor>/rector/rector-prefixed/rules/phpunit/src/Rector/MethodCall/AssertEqualsToSameRector.php:92 which is the return in this code snippet:

    private function getNodeType(\PhpParser\Node\Expr $expr) : \PHPStan\Type\Type
    {
        /** @var Scope $nodeScope */
        $nodeScope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
        return $nodeScope->getType($expr);
    }

Minimal PHP Code Causing Issue

https://getrector.org/demo/e3267adc-56d3-4fc6-a1d3-7c46c71d256a

Expected Behaviour

No error is thrown, refactor for assertEquals -> assertSame should still be applied

@Bl00D4NGEL Bl00D4NGEL added the bug label Mar 8, 2021
@TomasVotruba
Copy link
Member

Thank you for your report and demo link!

Could you send a failing test case in a pull-request, so we have it covered in Rector?
Here is step by step tutorial how to add it: https://github.com/rectorphp/rector/blob/master/docs/how_to_add_test_for_rector_rule.md

@Bl00D4NGEL Bl00D4NGEL changed the title [Phpunit] AssertPropertyExistsRector fails if markTest* exists in function [Phpunit] AssertEqualsToSameRector fails if markTest* exists in function Mar 8, 2021
@Bl00D4NGEL
Copy link
Contributor Author

Changed the title of the issue as I was confusing rectors. Created #5800 for the test fixtures

@Bl00D4NGEL
Copy link
Contributor Author

Issue fixed with #5800

@TomasVotruba
Copy link
Member

Thank you 👏

TomasVotruba added a commit that referenced this issue Apr 3, 2024
rectorphp/rector-src@8e022d1 ArgumentRemoverRectorTest: replace symfony\yaml reference with dummy (#5799)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants