Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Dom/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function fieldEquals(Selector|string|callable $selector, string $expected
{
$field = $this->field($selector);

if ($expected === $field->value()) {
if ($expected === (string) $field->value()) {
Assert::pass();

return $this;
Expand Down
12 changes: 12 additions & 0 deletions tests/AssertionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public function field_equals_for_input(): void
$this->assertion()->fieldEquals('#input1', 'input 1');
}

#[Test]
public function field_equals_for_empty_string(): void
{
$this->assertion()->fieldEquals('#empty-input', '');
}

#[Test]
public function field_equals_for_combobox_by_text(): void
{
Expand All @@ -149,6 +155,12 @@ public function field_selected_for_combobox(): void
$this->assertion()->fieldSelected('#input4', 'option 1');
}

#[Test]
public function field_placeholder_selected_for_combobox(): void
{
$this->assertion()->fieldSelected('#select-with-empty-value', '');
}

#[Test]
public function field_selected_for_multiselect_by_value(): void
{
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixtures/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ <h1>h1 title</h1>
<label for="title">Title</label>
<input type="text" id="title" name="title" value="initial title">

<label for="empty-input">Empty Input</label>
<input type="text" id="empty-input" name="empty_input" value="">

<label for="select-with-empty-value">Select with empty value</label>
<select id="select-with-empty-value" name="select_with_empty_value">
<option value=""></option>
<option value="1"></option>
<option value="2"></option>
</select>

<label for="input10">Input 10</label>
<select id="input10" name="input_10">
<option>option 1</option>
Expand Down