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

Fix error on resource assertion if message has a second placeholder #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cs278
Copy link

@cs278 cs278 commented Jun 13, 2024

Prior to this change code such as
Assert::resource(null, 'stream', 'Got: %s, type: %s') would fail as
the second placeholder was only passed into sprintf() if the value
supplied is a resource.

Test I've added without the code change fails with:

1) Webmozart\Assert\Tests\AssertTest::testResourceOfTypeCustomMessage
Failed asserting that exception of type "ArgumentCountError" matches expected exception "\InvalidArgumentException". Message was: "3 arguments are required, 2 given" at
<snip>/src/Assert.php:255
<snip>/tests/AssertTest.php:827

Prior to this change code such as
`Assert::resource(null, 'stream', 'Got: %s, type: %s')` would fail as
the second placeholder was only passed into `sprintf()` if the value
supplied is a resource.

Test I've added without the code change fails with:

```
1) Webmozart\Assert\Tests\AssertTest::testResourceOfTypeCustomMessage
Failed asserting that exception of type "ArgumentCountError" matches expected exception "\InvalidArgumentException". Message was: "3 arguments are required, 2 given" at
<snip>/src/Assert.php:255
<snip>/tests/AssertTest.php:827
```
@cs278
Copy link
Author

cs278 commented Jun 13, 2024

I came to the conclusion a bespoke test was needed but I might have missed something.

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.

1 participant