protected function ContentTranslationFieldSyncRevisionTest::assertViolations in Drupal 9
Same name and namespace in other branches
- 8 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()
Asserts that the expected violations were found.
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 453
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function assertViolations(EntityConstraintViolationListInterface $violations) {
$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);
}