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

Error when mocking anonymous classes #1414

Closed
lew-tfli opened this issue Apr 26, 2024 · 2 comments · Fixed by #1415
Closed

Error when mocking anonymous classes #1414

lew-tfli opened this issue Apr 26, 2024 · 2 comments · Fixed by #1415
Assignees
Labels
Bug An error or unexpected behavior. Regression for unintended bugs that arise after making changes or updates
Milestone

Comments

@lew-tfli
Copy link

Mockery Version

1.6.10

PHP Version

PHP 8.2

Issue Description

On Mockery version 1.6.10 and above, an exception is thrown when mocking an anonymous class. The issue does not exist in 1.6.9.

class AnonClassTest extends Mockery\Adapter\Phpunit\MockeryTestCase {
    public function testA() {
        $class = new class() extends \stdClass {};
        $mock = Mockery::mock($class::class);
    }
}

Steps to Reproduce

No response

Expected Behavior

The mock is created successfully

Actual Behavior

An exception is thrown

Exception or Error

Mockery\Exception: Class name contains invalid characters

Additional Information

No response

@lew-tfli lew-tfli added the triage needs to be triaged label Apr 26, 2024
@ghostwriter ghostwriter added Bug An error or unexpected behavior. Regression for unintended bugs that arise after making changes or updates and removed triage needs to be triaged labels Apr 26, 2024
@ghostwriter ghostwriter self-assigned this Apr 26, 2024
@ghostwriter ghostwriter added this to the 1.6.12 milestone Apr 26, 2024
@ghostwriter
Copy link
Member

Hey @lew-tfli,

Thank you for bringing this issue to our attention.

I've created a pull request to resolve this in #1415.

Could you please test the fix branch using the following command:

composer require mockery/mockery:dev-regression/issue-1414/mock-anonymous-classes --dev

Your feedback on whether the fix resolves the issue would be greatly appreciated.

@lew-tfli
Copy link
Author

Hi @ghostwriter, this has fixed the issue.

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An error or unexpected behavior. Regression for unintended bugs that arise after making changes or updates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants