diff --git a/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinks.php b/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinks.php
similarity index 58%
rename from docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinks.php
rename to docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinks.php
index 15bc251ab7d..1be9bd716a6 100644
--- a/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinks.php
+++ b/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinks.php
@@ -5,33 +5,33 @@
use Symfony\Component\Validator\Constraint;
/**
- * Checks that the text does not use any preview URLs as paths.
+ * Checks that the text does not use any preview URL links.
*
* In other words, we want to avoid things like this:
*
- * `VA.gov`
+ * `VA.gov`
*
* @Constraint(
- * id = "PreventPreviewUrlsAsPathsInLinks",
- * label = @Translation("Prevent Preview URLs as Paths in Links", context = "Validation"),
+ * id = "PreventPreviewUrlLinks",
+ * label = @Translation("Prevent Preview URL Links", context = "Validation"),
* type = { "string_long", "text_long" }
* )
*/
-class PreventPreviewUrlsAsPathsInLinks extends Constraint {
+class PreventPreviewUrlLinks extends Constraint {
/**
* The error message for plain text fields.
*
* @var string
- * @see \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinksValidator
+ * @see \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinksValidator
*/
- public $plainTextMessage = 'Replace the preview link ":url" with a public URL.';
+ public $plainTextMessage = 'Replace the preview URL ":url" with a public URL.';
/**
* The error message for rich text fields.
*
* @var string
- * @see \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinksValidator
+ * @see \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinksValidator
*/
public $richTextMessage = 'Review the linked text ":link" (:url) and replace the preview URL with a public URL.';
diff --git a/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinksValidator.php b/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinksValidator.php
similarity index 91%
rename from docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinksValidator.php
rename to docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinksValidator.php
index 445752f2514..4c23281806f 100644
--- a/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlsAsPathsInLinksValidator.php
+++ b/docroot/modules/custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventPreviewUrlLinksValidator.php
@@ -9,9 +9,9 @@
use Symfony\Component\Validator\ConstraintValidator;
/**
- * Validates the PreventPreviewUrlsAsPathsInLinks constraint.
+ * Validates the PreventPreviewUrlLinks constraint.
*/
-class PreventPreviewUrlsAsPathsInLinksValidator extends ConstraintValidator {
+class PreventPreviewUrlLinksValidator extends ConstraintValidator {
use TextValidatorTrait;
use ValidatorContextAccessTrait;
@@ -37,7 +37,7 @@ public function validateText(string $text, Constraint $constraint, int $delta) {
*
* In other words, we look for a string that looks like a preview URL.
*/
- /** @var \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinks $constraint */
+ /** @var \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinks $constraint */
if (preg_match('#(https?://preview-(staging|prod).vfs.va.gov[^\s]+)#', $text, $matches)) {
$this->addViolation($delta, $constraint->plainTextMessage, [
':url' => $matches[1],
@@ -49,7 +49,7 @@ public function validateText(string $text, Constraint $constraint, int $delta) {
* {@inheritdoc}
*/
public function validateHtml(string $html, Constraint $constraint, int $delta) {
- /** @var \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinks $constraint */
+ /** @var \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinks $constraint */
$dom = Html::load($html);
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//a[contains(@href, "preview-staging.vfs.va.gov") or contains(@href, "preview-prod.vfs.va.gov")]') as $element) {
diff --git a/docroot/modules/custom/va_gov_backend/va_gov_backend.module b/docroot/modules/custom/va_gov_backend/va_gov_backend.module
index 064292c81ad..b98edea58c4 100644
--- a/docroot/modules/custom/va_gov_backend/va_gov_backend.module
+++ b/docroot/modules/custom/va_gov_backend/va_gov_backend.module
@@ -1323,7 +1323,7 @@ function va_gov_backend_entity_bundle_field_info_alter(&$fields, EntityTypeInter
$field->addConstraint('PreventAbsoluteUrlsAsPathsInLinks');
$field->addConstraint('PreventVaGovDomainsAsPathsInLinks');
$field->addConstraint('PreventDomainsAsPathsInLinks');
- $field->addConstraint('PreventPreviewUrlsAsPathsInLinks');
+ $field->addConstraint('PreventPreviewUrlLinks');
}
elseif ($field->getType() === 'text_long') {
$field->addConstraint('PreventAbsoluteCmsLinks');
@@ -1333,7 +1333,7 @@ function va_gov_backend_entity_bundle_field_info_alter(&$fields, EntityTypeInter
$field->addConstraint('PreventAbsoluteUrlsAsPathsInLinks');
$field->addConstraint('PreventVaGovDomainsAsPathsInLinks');
$field->addConstraint('PreventDomainsAsPathsInLinks');
- $field->addConstraint('PreventPreviewUrlsAsPathsInLinks');
+ $field->addConstraint('PreventPreviewUrlLinks');
}
}
// Add paragraph checks on clp panels.
diff --git a/tests/phpunit/Content/PreventPreviewUrlsAsPathsInLinksValidatorTest.php b/tests/phpunit/Content/PreventPreviewUrlLinksValidatorTest.php
similarity index 87%
rename from tests/phpunit/Content/PreventPreviewUrlsAsPathsInLinksValidatorTest.php
rename to tests/phpunit/Content/PreventPreviewUrlLinksValidatorTest.php
index 1f7e0dc4f29..e24c684502d 100644
--- a/tests/phpunit/Content/PreventPreviewUrlsAsPathsInLinksValidatorTest.php
+++ b/tests/phpunit/Content/PreventPreviewUrlLinksValidatorTest.php
@@ -2,8 +2,8 @@
namespace tests\phpunit\Content;
-use Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinks;
-use Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlsAsPathsInLinksValidator;
+use Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinks;
+use Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventPreviewUrlLinksValidator;
use Tests\Support\Classes\VaGovUnitTestBase;
use Tests\Support\Traits\ValidatorTestTrait;
@@ -16,7 +16,7 @@
*
* @coversDefaultClass \Drupal\va_gov_backend\Plugin\Validation\Constraint\PreventProtocolRelativeLinksValidator
*/
-class PreventPreviewUrlsAsPathsInLinksValidatorTest extends VaGovUnitTestBase {
+class PreventPreviewUrlLinksValidatorTest extends VaGovUnitTestBase {
use ValidatorTestTrait;
@@ -26,7 +26,7 @@ class PreventPreviewUrlsAsPathsInLinksValidatorTest extends VaGovUnitTestBase {
* @covers ::addViolation
*/
public function testAddViolation() {
- $validator = new PreventPreviewUrlsAsPathsInLinksValidator();
+ $validator = new PreventPreviewUrlLinksValidator();
$this->prepareValidator($validator, FALSE);
$validator->addViolation(3, 'Test violation');
}
@@ -58,9 +58,9 @@ public function testValidate(bool $willValidate, string $testString, string $fie
$items = $this->getFieldItemList([
$this->getFieldItem($value, $fieldType),
]);
- $validator = new PreventPreviewUrlsAsPathsInLinksValidator();
+ $validator = new PreventPreviewUrlLinksValidator();
$this->prepareValidator($validator, $willValidate);
- $validator->validate($items, new PreventPreviewUrlsAsPathsInLinks());
+ $validator->validate($items, new PreventPreviewUrlLinks());
}
/**
@@ -78,11 +78,11 @@ public function validateDataProvider() {
],
[
FALSE,
- 'However, string_long text with http://preview-staging.vfs.va.gov/path/to/content a path that consists of an Preview URL should fail validation.',
+ 'However, string_long text with http://preview-staging.vfs.va.gov/path/to/content that consists of an Preview URL should fail validation.',
],
[
FALSE,
- 'However, string_long text with http://preview-prod.vfs.va.gov/path/to/content a path that consists of an Preview URL should fail validation.',
+ 'However, string_long text with http://preview-prod.vfs.va.gov/path/to/content that consists of an Preview URL should fail validation.',
],
[
TRUE,