You are here

protected function SmartlingTestBase::checkGeneratedFile in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/SmartlingTestBase.php \Drupal\Tests\tmgmt_smartling\Functional\SmartlingTestBase::checkGeneratedFile()

Checks if generated file exists and correct.

Parameters

$fileName:

$nodeTitle:

string $format:

7 calls to SmartlingTestBase::checkGeneratedFile()
BaseFlowTest::testUploadFileAndDownloadTranslation in tests/src/Functional/BaseFlowTest.php
Test upload and download translation.
ContextTest::testSmartlingContextDebuggerSendContext in tests/src/Functional/ContextTest.php
Test Smartling context debugger: send context.
PushBackControllerTest::testPushBackExistingJobWithoutFileUri in tests/src/Functional/PushBackControllerTest.php
Push back existing job without file uri.
PushBackControllerTest::testPushBackExistingJobWithoutLocale in tests/src/Functional/PushBackControllerTest.php
Push back existing job without locale.
PushBackControllerTest::testPushBackExistingJobWithoutLocaleAndFileUri in tests/src/Functional/PushBackControllerTest.php
Push back existing job without parameters.

... See full list

File

tests/src/Functional/SmartlingTestBase.php, line 232

Class

SmartlingTestBase
Basic tests for the Smartling translator.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

protected function checkGeneratedFile($fileName, $nodeTitle, $format = 'xml') {
  $file_path = \Drupal::getContainer()
    ->get('file_system')
    ->realpath(\Drupal::config('system.file')
    ->get('default_scheme') . "://tmgmt_sources/{$fileName}");
  $content = file_get_contents($file_path);
  $this
    ->assertTrue(strpos($content, $nodeTitle) !== FALSE, 'Title is in file');
  $no_directives = $format != 'xml';
  $this
    ->assertTrue(strpos($content, '<limit>255</limit>') !== $no_directives);
  $this
    ->assertTrue(strpos($content, '<span sl-variant="node-3-title][0][value" class="atom" id="bMV1bdGl0bGVdWzBdW3ZhbHVl">') !== $no_directives);
  $this
    ->assertTrue(strpos($content, '<limit>NONE</limit>') !== $no_directives);
  $this
    ->assertTrue(strpos($content, '<div sl-variant="node-3-body][0][value" class="atom" id="bMV1bYm9keV1bMF1bdmFsdWU">') !== $no_directives);
}