function CKEditor5ValidationTestTrait::validatePairToViolationsArray
Same name in other branches
- 10 core/modules/ckeditor5/tests/src/Kernel/CKEditor5ValidationTestTrait.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5ValidationTestTrait::validatePairToViolationsArray()
- 11.x core/modules/ckeditor5/tests/src/Kernel/CKEditor5ValidationTestTrait.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5ValidationTestTrait::validatePairToViolationsArray()
Decorator for CKEditor5::validatePair() that returns an assertable array.
Parameters
\Drupal\editor\EditorInterface $text_editor: The paired text editor to validate.
\Drupal\filter\FilterFormatInterface $text_format: The paired text format to validate.
bool $all_compatibility_problems: Only fundamental compatibility violations are returned unless TRUE.
Return value
array An array with property paths as keys and violation messages as values.
See also
\Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair
2 calls to CKEditor5ValidationTestTrait::validatePairToViolationsArray()
- SmartDefaultSettingsTest::test in core/
modules/ ckeditor5/ tests/ src/ Kernel/ SmartDefaultSettingsTest.php - Tests the CKEditor 5 default settings conversion.
- ValidatorsTest::testPair in core/
modules/ ckeditor5/ tests/ src/ Kernel/ ValidatorsTest.php - @covers \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair() @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator @covers…
File
-
core/
modules/ ckeditor5/ tests/ src/ Kernel/ CKEditor5ValidationTestTrait.php, line 31
Class
- CKEditor5ValidationTestTrait
- Defines a trait for testing CKEditor 5 validity.
Namespace
Drupal\Tests\ckeditor5\KernelCode
private function validatePairToViolationsArray(EditorInterface $text_editor, FilterFormatInterface $text_format, bool $all_compatibility_problems) : array {
$violations = CKEditor5::validatePair($text_editor, $text_format, $all_compatibility_problems);
$actual_violations = [];
foreach ($violations as $violation) {
if (!isset($actual_violations[$violation->getPropertyPath()])) {
$actual_violations[$violation->getPropertyPath()] = (string) $violation->getMessage();
}
else {
// Transform value from string to array.
if (is_string($actual_violations[$violation->getPropertyPath()])) {
$actual_violations[$violation->getPropertyPath()] = (array) $actual_violations[$violation->getPropertyPath()];
}
// And append.
$actual_violations[$violation->getPropertyPath()][] = (string) $violation->getMessage();
}
}
return $actual_violations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.