Skip to content

Commit 4a6f37a

Browse files
authored
Merge pull request #176 from stof/fix_tests
Fix the validation of invalid values in tests
2 parents 796b01f + bee9b4d commit 4a6f37a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/BrowserKitDriver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function setValue(string $xpath, $value)
424424
}
425425

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

430430
$field->setValue($value);
@@ -592,6 +592,12 @@ protected function prepareUrl(string $url)
592592
protected function getFormField(string $xpath)
593593
{
594594
$fieldNode = $this->getCrawlerNode($this->getFilteredCrawler($xpath));
595+
$fieldType = $fieldNode->getAttribute('type');
596+
597+
if (\in_array($fieldType, ['button', 'submit', 'image'], true)) {
598+
throw new DriverException(sprintf('Cannot access a form field of type "%s".', $fieldType));
599+
}
600+
595601
$fieldName = str_replace('[]', '', $fieldNode->getAttribute('name'));
596602

597603
$formNode = $this->getFormNode($fieldNode);

0 commit comments

Comments
 (0)