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

Add actual function that can be mocked in PHPUnit 12 #13

Merged
merged 1 commit into from
Mar 7, 2025

Conversation

crocodele
Copy link
Contributor

@michalbundyra
Copy link
Member

@crocodele thanks for this PR. Before I publish stable version I would like to make sure that it all works with current versions of our satellite packages - phpunit, prophecy and mockery.
All these changes here are internal and I believe there is no BC Break, but just to make sure we are still fine with other packages.
I'll create beta release so then we can try the other packages with beta, and once we get there working PRs I'll publish a stable.

Would it work for you?

Thanks

@michalbundyra michalbundyra added this to the 2.5.0 milestone Mar 7, 2025
@michalbundyra michalbundyra merged commit c9a7388 into php-mock:master Mar 7, 2025
14 checks passed
@michalbundyra
Copy link
Member

@crocodele please see: php-mock/php-mock-phpunit#77

It looks like it's not working atm. I haven't tried mockery or prophecy yet, feel free to try if you have a minute. Thanks

@crocodele crocodele deleted the feature/SupportPhpUnit12 branch March 7, 2025 14:33
@crocodele
Copy link
Contributor Author

crocodele commented Mar 7, 2025

Cheers @michalbundyra!

I suppose this will require a breaking change and hence a new major version 3.0.0, because in php-mock-phpunit:

  1. addMethods() can no longer be used now that the method is actually in the class (Trying to configure method "sqrt" with addMethods(), but it exists in class "phpmock\integration62570404d3773f165e00844cef2e111a\MockDelegateFunction". Use onlyMethods() for methods that exist in the class)
  2. getMockForAbstractClass() probably fails too now that the class is no longer abstract.

I updated the PR in php-mock-phpunit to use 2.5.0-beta1, let's see if the tests now pass. 🤞

I'll also have a look at php-mock-prophecy and php-mock-mockery to see if any changes are required there.

@@ -52,11 +52,13 @@ public function build($functionName = null)
$parameterBuilder->build($functionName === null ? '' : $functionName);
$signatureParameters = $parameterBuilder->getSignatureParameters();

$populatedFunctionName = $functionName === null ? '_dummy' : $functionName;
Copy link
Member

Choose a reason for hiding this comment

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

@crocodele actually I am thinking if we should even create a method in the class, when the function name is null?

I am not really sure why we even allow the function name to be null here, and it looks like the null value is not even used in the satellite packages.

Also I wonder if we should be creating the method with a signatureParameters? As I see all seems to be working fine without the 'correct signature' tho 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants