You are here

public function LoggingTest::testTrackEntityChangesEventLogging in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/LoggingTest.php \Drupal\Tests\tmgmt_smartling\Functional\LoggingTest::testTrackEntityChangesEventLogging()

Test request translation track entity changes logging.

File

tests/src/Functional/LoggingTest.php, line 108

Class

LoggingTest
Logging tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testTrackEntityChangesEventLogging() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    $this->userForTranslations = $this
      ->loginAsAdmin([
      'edit any translatable_node content',
      'access site reports',
    ]);

    // Create a job. It is needed for test.
    $translator = $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $this
      ->requestTranslationForNode($this->testNodeId, 'de', $translator);

    // Clean log messages after job submission.
    $this
      ->drupalPostForm('/admin/reports/dblog/confirm', [], t('Confirm'));
    $node = Node::load($this->testNodeId);
    $node
      ->setTitle('New title');
    $node
      ->save();
    $this
      ->drupalGet('/admin/reports/dblog');

    // File triggered/queued.
    $this
      ->assertNoRaw('File upload triggered (request translation). Job id: 1, file name: JobID1_en_de.xml.');
    $this
      ->assertRaw('File upload queued (track entity changes). Job id: 1, file name: JobID1_en_de.xml.');

    // File uploaded.
    $this
      ->assertNoRaw('File uploaded. Job id: 1, file name: JobID1_en_de.xml.');
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}