diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php index f091e52e..a8cb459a 100644 --- a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php +++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php @@ -58,7 +58,10 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi $this->assertRaw(t('Saved %label configuration.', ['%label' => $label])); // Check that the field appears in the overview form. - $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]"); + $xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [ + ':label' => $label, + ]); + $this->assertSession()->elementExists('xpath', $xpath); } /** @@ -95,7 +98,10 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l $this->assertRaw(t('Saved %label configuration.', ['%label' => $label])); // Check that the field appears in the overview form. - $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]"); + $xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [ + ':label' => $label, + ]); + $this->assertSession()->elementExists('xpath', $xpath); } /** @@ -123,7 +129,10 @@ public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_la $this->assertRaw(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label])); // Check that the field does not appear in the overview form. - $this->assertSession()->elementNotExists('xpath', '//table[@id="field-overview"]//span[@class="label-field" and text()="' . $label . '"]'); + $xpath = $this->assertSession()->buildXPathQuery('//table[@id="field-overview"]//span[@class="label-field" and text()= :label]', [ + ':label' => $label, + ]); + $this->assertSession()->elementNotExists('xpath', $xpath); } }