-
Notifications
You must be signed in to change notification settings - Fork 2
Custom AssertableHtmlElement classes #5
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
Conversation
@@ -41,18 +42,23 @@ public function test_assertable_html(): void | |||
<li id="baz">Baz</li> | |||
</ul> | |||
|
|||
<!-- Custom Element --> |
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.
Need separate test methods per promoted/custom element in new PR.
* Assert only if the given input is null. | ||
* Useful if you want to fail when a child element isn't matched before attempting to chain on more assertions. | ||
*/ | ||
protected function assertIfNull(mixed $value, ?string $message = null): static |
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.
Need something like this in new PR? Maybe something that accepts a callback?
use Ziadoz\AssertableHtml\Contracts\AssertableHtmlElementMatcherInterface; | ||
use Ziadoz\AssertableHtml\Dom\AssertableHtmlElement; | ||
|
||
readonly class AssertableHtmlFormElement extends AssertableHtmlElement implements AssertableHtmlElementMatcherInterface |
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.
Need to port bits over from this into new PR.
/** Assert the form's hidden _method input matches the given value. */ | ||
private function assertHiddenInputMethod(string $method, ?string $message = null): static | ||
{ | ||
$this->assertIfNull($this->querySelector('input[type="hidden"][name="_method"]'), sprintf( |
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.
In new PR could this be:
$this->assertPresent('input[type="hidden"][name="_method"]')->assertAttribute('value', 'delete');
Would need to add assertPresent/Missing()
aliases to assertCount()
for element. Might also want an attribute case insensitive/trimmed assertion, as will be useful for GET
vs get
etc.
This PR adds the ability to return custom element assertable classes:
Investigate original upgradable element idea:
$assertableElement->upgrade()
which returnsAssertableFormElement
.