Skip to content

Commit

Permalink
Merge pull request #183 from aik099/setvalue-checkbox-validation-feat
Browse files Browse the repository at this point in the history
Throw exception, when doing a "setValue" call on checkbox with a non-boolean value
  • Loading branch information
stof authored Jan 9, 2025
2 parents 7a74a76 + 0fbf050 commit 207f8a5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/BrowserKitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ public function setValue(string $xpath, $value)
throw new DriverException('Only string values can be used for a radio input.');
}

if (!\is_bool($value) && $field->getType() === 'checkbox') {
throw new DriverException('Only boolean values can be used for a checkbox input.');
}

if (\is_bool($value) && $field->getType() === 'select') {
throw new DriverException('Boolean values cannot be used for a select element.');
}
Expand Down

0 comments on commit 207f8a5

Please sign in to comment.