You are here

protected function ContentTranslationSyncUnitTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php \Drupal\content_translation\Tests\ContentTranslationSyncUnitTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides KernelTestBase::setUp

File

core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php, line 64
Contains \Drupal\content_translation\Tests\ContentTranslationSyncUnitTest.

Class

ContentTranslationSyncUnitTest
Tests the field synchronization logic.

Namespace

Drupal\content_translation\Tests

Code

protected function setUp() {
  parent::setUp();
  $this->synchronizer = new FieldTranslationSynchronizer($this->container
    ->get('entity.manager'));
  $this->synchronized = array(
    'sync1',
    'sync2',
  );
  $this->columns = array_merge($this->synchronized, array(
    'var1',
    'var2',
  ));
  $this->langcodes = array(
    'en',
    'it',
    'fr',
    'de',
    'es',
  );
  $this->cardinality = 4;
  $this->unchangedFieldValues = array();

  // Set up an initial set of values in the correct state, that is with
  // "synchronized" values being equal.
  foreach ($this->langcodes as $langcode) {
    for ($delta = 0; $delta < $this->cardinality; $delta++) {
      foreach ($this->columns as $column) {
        $sync = in_array($column, $this->synchronized) && $langcode != $this->langcodes[0];
        $value = $sync ? $this->unchangedFieldValues[$this->langcodes[0]][$delta][$column] : $langcode . '-' . $delta . '-' . $column;
        $this->unchangedFieldValues[$langcode][$delta][$column] = $value;
      }
    }
  }
}