/**
* Get the selected value from a select field.
*
* @param \Symfony\Component\DomCrawler\Crawler $select
* @return array
*/
protected function getSelectedValueFromSelect(Crawler $select)
{
$selected = [];
foreach ($select->children() as $option) {
if ($option->nodeName === 'optgroup') {
foreach ($option->childNodes as $child) {
if ($child->hasAttribute('selected')) {
$selected[] = $this->getOptionValue($child);
}
}
} elseif ($option->hasAttribute('selected')) {
$selected[] = $this->getOptionValue($option);
}
}
return $selected;
}