Skip to content

Commit

Permalink
Fix the validation of invalid values in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Nov 29, 2023
1 parent 796b01f commit bee9b4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/BrowserKitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public function setValue(string $xpath, $value)
}

if (\is_array($value) || \is_bool($value)) {
throw new DriverException('Textual and file form fields don\'t support array or boolean values');
throw new DriverException('Textual and file form fields don\'t support array or boolean values.');
}

$field->setValue($value);
Expand Down Expand Up @@ -592,6 +592,12 @@ protected function prepareUrl(string $url)
protected function getFormField(string $xpath)
{
$fieldNode = $this->getCrawlerNode($this->getFilteredCrawler($xpath));
$fieldType = $fieldNode->getAttribute('type');

if (\in_array($fieldType, ['button', 'submit', 'image'], true)) {
throw new DriverException(sprintf('Cannot access a form field of type "%s".', $fieldType));
}

$fieldName = str_replace('[]', '', $fieldNode->getAttribute('name'));

$formNode = $this->getFormNode($fieldNode);
Expand Down

0 comments on commit bee9b4d

Please sign in to comment.