You are here

public function LoggingTest::testTrackEntityChangesEventLogging in TMGMT Translator Smartling 8.2

Test request translation track entity changes logging.

File

src/Tests/LoggingTest.php, line 150

Class

LoggingTest
Logging tests.

Namespace

Drupal\tmgmt_smartling\Tests

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
      ->assertNoRaw('File upload queued (request translation in a batch). Job id: 1, file name: JobID1_en_de.xml.');
    $this
      ->assertNoRaw('File upload triggered (view action). 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.");
  }
}