You are here

protected function ContentTranslationFieldSyncRevisionTest::assertViolations in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::assertViolations()
  2. 9 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.

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\Kernel

Code

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);
}