protected function FileTranslatorTest::assertIntegrityCheck

Asserts import integrity for a job.

Parameters

\Drupal\tmgmt\JobInterface $job: The job to check.

bool $expected: (optional) If an integrity failed message is expected or not, defaults to FALSE.

1 call to FileTranslatorTest::assertIntegrityCheck()
FileTranslatorTest::testXLIFFTextProcessing in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Test the content processing for XLIFF export and import.

File

translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php, line 580

Class

FileTranslatorTest
Tests for the file translator.

Namespace

Drupal\Tests\tmgmt_file\Functional

Code

protected function assertIntegrityCheck(JobInterface $job, $expected = TRUE) {
  $integrity_check_failed = FALSE;

  /** @var \Drupal\tmgmt\MessageInterface $message */
  foreach ($job
    ->getMessages() as $message) {
    if ($message
      ->getMessage() == new TranslatableMarkup('Failed to validate semantic integrity of %key element. Please check also the HTML code of the element in the review process.', array(
      '%key' => 'dummy][deep_nesting',
    ))) {
      $integrity_check_failed = TRUE;
      break;
    }
  }

  // Check if the message was found or not, based on the expected argument.
  if ($expected) {
    $this
      ->assertTrue($integrity_check_failed, 'The validation of semantic integrity must fail.');
  }
  else {
    $this
      ->assertFalse($integrity_check_failed, 'The validation of semantic integrity must not fail.');
  }
}