Skip to content

Commit

Permalink
Fix issue where child node is DOMText
Browse files Browse the repository at this point in the history
REBELinBLUE committed May 7, 2020

Unverified

This user has not yet uploaded their public signing key.
1 parent 67776f0 commit 0711e61
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Constraints/IsSelected.php
Original file line number Diff line number Diff line change
@@ -42,11 +42,11 @@ protected function getSelectedValueFromSelect(Crawler $select): array
foreach ($select->children() as $option) {
if ($option->nodeName === 'optgroup') {
foreach ($option->childNodes as $child) {
if ($child->hasAttribute('selected')) {
if ($child instanceof DOMElement && $child->hasAttribute('selected')) {
$selected[] = $this->getOptionValue($child);
}
}
} elseif ($option->hasAttribute('selected')) {
} elseif ($option instanceof DOMElement && $option->hasAttribute('selected')) {
$selected[] = $this->getOptionValue($option);
}
}
@@ -66,7 +66,7 @@ protected function getOptionValue(DOMElement $option): string
protected function getCheckedValueFromRadioGroup(Crawler $radioGroup): ?string
{
foreach ($radioGroup as $radio) {
if ($radio->hasAttribute('checked')) {
if ($radio instanceof DOMElement && $radio->hasAttribute('checked')) {
return $radio->getAttribute('value');
}
}
4 changes: 2 additions & 2 deletions tests/CrawlerTestAssertions.php
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@

abstract class CrawlerTestAssertions extends PHPUnit_Framework_TestCase
{
/** @var GoutteClient $client */
/** @var GoutteClient */
protected $client;

/** @var Crawler $crawler */
/** @var Crawler */
protected $crawler;

/** @var array */

0 comments on commit 0711e61

Please sign in to comment.