function ContentTranslationFieldSyncRevisionTest::assertViolations
Same name in other branches
- 8.9.x core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertViolations()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertViolations()
- 11.x core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertViolations()
Asserts that the expected violations were found.
@internal
Parameters
\Drupal\Core\Entity\EntityConstraintViolationListInterface $violations: A list of violations.
1 call to ContentTranslationFieldSyncRevisionTest::assertViolations()
- ContentTranslationFieldSyncRevisionTest::testFieldSynchronizationAndValidation in core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php - Checks that field synchronization works as expected with revisions.
File
-
core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php, line 455
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function assertViolations(EntityConstraintViolationListInterface $violations) : void {
$entity_type_id = $this->storage
->getEntityTypeId();
$settings = $this->contentTranslationManager
->getBundleTranslationSettings($entity_type_id, $entity_type_id);
$message = !empty($settings['untranslatable_fields_hide']) ? 'Non-translatable field elements can only be changed when updating the original language.' : 'Non-translatable field elements can only be changed when updating the current revision.';
$list = [];
foreach ($violations as $violation) {
if ((string) $violation->getMessage() === $message) {
$list[] = $violation;
}
}
$this->assertCount(1, $list);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.