MDL-85565 phpunit: check for <select> before <option>

Make sure that assert_select_options() will fail when the output does
not contain a <select> and therefore does not have the given options.
This commit is contained in:
Philipp Imhof
2025-07-25 13:13:52 +02:00
parent 4ea8645494
commit e4c6d0b498
+1
View File
@@ -574,6 +574,7 @@ abstract class question_testcase extends advanced_testcase {
$dom = new DOMDocument();
$dom->loadHTML($html);
$selects = $dom->getElementsByTagName('select');
$this->assertGreaterThanOrEqual(1, $selects->count(), 'There is no <select> in the output.');
foreach ($selects as $select) {
if ($select->getAttribute('name') == $expectation->name) {
$options = $select->getElementsByTagName('option');