diff --git a/htdocs/artefact/comment/lib.php b/htdocs/artefact/comment/lib.php index cae12033b821021021284c00dcaaaf0ca6218c88..9f05338a34d1f3c025b41baf70190a35d319f851 100644 --- a/htdocs/artefact/comment/lib.php +++ b/htdocs/artefact/comment/lib.php @@ -1172,12 +1172,15 @@ class ArtefactTypeComment extends ArtefactType { /* - * Removes the classes from the text of the comment thst could interfere + * Removes the classes from the text of the comment that could interfere * with the comment display * @param string $comment the text content of the comment */ public static function remove_comments_classes($comment) { + if (empty($comment)) { + return ""; + } $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; diff --git a/htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php b/htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php index 3e06974ea27787cc0f27a907443031e57a9bbda1..2f11b60f841e07453c8996649253ab10116aa5e8 100644 --- a/htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php +++ b/htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php @@ -380,15 +380,17 @@ class BehatDataGenerators extends BehatBase { * @param array ('field' => 'values', ...) $record * @return $record */ - public function normalise(&$record) { - foreach ($record as &$value) { - $value = trim($value); - // Normalise boolean values - if (strtolower($value) == 'on' || $value == '1' || $value == 'true') { - $value = true; - } - else if (strtolower($value) == 'off' || $value == '0' || $value == 'false') { - $value = false; + public function normalise($availablefields, &$record) { + foreach ($record as $fieldname => &$value) { + if ($availablefields[$fieldname] == 'bool') { + $value = trim($value); + // Normalise boolean values + if (strtolower($value) == 'on' || $value == '1' || $value == 'yes' || $value == 'true') { + $value = true; + } + else if (strtolower($value) == 'off' || $value == '0' || $value == 'no' || $value == 'false') { + $value = false; + } } } } @@ -447,7 +449,7 @@ class BehatDataGenerators extends BehatBase { foreach ($data->getHash() as $elementdata) { // Normalise field values - $this->normalise($elementdata); + $this->normalise($availablefields, $elementdata); // Validate available fields for given element $this->validate_fields($availablefields, $elementdata); // Check if all the required fields are there.