-
Notifications
You must be signed in to change notification settings - Fork 25
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 objectHasProperty assertions #57
Add objectHasProperty assertions #57
Conversation
@@ -46,4 +46,30 @@ public function notHasAttribute(string $attributeName, string $message = ''): se | |||
Assert::assertObjectNotHasAttribute($attributeName, $this->actual, $message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @deprecated Deprecated in favour of hasProperty
annotation to hasAttribute
and hasAttribute
.
To keep these old methods working, they could be updated to call Assert::assertObjectHasProperty
and Assert::assertObjectNotHasProperty
accordingly, right?
The lowest supported version of phpunit could be set to ^9.6.11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in theory, the old methods could call the new ones, or directly the new phpunit assertions.
That might be an idea for a temporary solution until the old ones are dropped completely.
I actually thought to keep them around since this library supports both 9.x and 10.x of phpunit, otherwise they could probably be dropped completely.
But, since they've been added in 9.6.11, it's probably the best solution to keep the old ones, alias them to the new assertions, and raise the minimum 9.x version, as you suggested. That wouldn't require a BC release.
Will update accordingly
docs/supported_expectations.md
Outdated
@@ -23,6 +23,8 @@ toHaveSameSizeAs | |||
``` | |||
notToHaveAttribute | |||
toHaveAttribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark old method as deprecated or remove them completely.
By the way, link to docs dir in README.md are broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.. technically, the links should work starting with /
, github docs specifically say those are relative to the repository root. Yet, they are not.
Maybe it's a special case for /docs
, since that also houses github docs itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the attribute assertions from the expectations and verifier docs, and attempted a fix at the README... the README links now should work, yet I am unable to test it since if I render it on my branch, it's relative to the /tree/
url.
Version 9.6.11 had the new asssertObjectHasProperty method added, which completely replace the assertObjectHasAttribute ones in phpunit 10.x
In theory, github markdown docs say that: > Links starting with / will be relative to the repository root. Yet, they are resolved to be relative to the github.com domain. Maybe it's a special case with the `/docs` , since that also references the actual github docs. Changed them to explicit relative links.
Can we get this merged? :) |
With phpunit 10.x,
assertObjectHasAttribute
is deprecated in favor ofassertObjectHasProperty
This adds the new alternatives.
See sebastianbergmann/phpunit#4601