You are here

LingotekConfigDependenciesPostUpdateTest.php in Lingotek Translation 8

File

src/Tests/Update/LingotekConfigDependenciesPostUpdateTest.php
View source
<?php

namespace Drupal\lingotek\Tests\Update;

use Drupal\lingotek\Entity\LingotekConfigMetadata;
use Drupal\system\Tests\Update\UpdatePathTestBase;

/**
 * Tests the upgrade path for updating the Lingotek metadata config dependencies.
 *
 * @group lingotek
 */
class LingotekConfigDependenciesPostUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../tests/fixtures/update/drupal-8.lingotek.standard.8x19.php.gz',
      __DIR__ . '/../../../tests/fixtures/update/metadata-config-dependencies-post-update.php',
    ];
  }

  /**
   * Tests that the Lingotek metadata dependencies are updated correctly.
   */
  public function testLingotekMetadataConfigDependenciesPostUpdate() {

    // The dependencies are wrong.
    $type_metadata = LingotekConfigMetadata::load('node_type.article');
    $type_dependencies = $type_metadata
      ->getDependencies();
    $this
      ->assertEqual('node_type.article', $type_dependencies['config'][0]);
    $field_metadata = LingotekConfigMetadata::load('field_config.node.article.body');
    $field_dependencies = $field_metadata
      ->getDependencies();
    $this
      ->assertEqual('field_config.node.article.body', $field_dependencies['config'][0]);
    $this
      ->runUpdates();

    // The dependencies are calculated correctly.
    $type_metadata = LingotekConfigMetadata::load('node_type.article');
    $type_dependencies = $type_metadata
      ->getDependencies();
    $this
      ->assertEqual('node.type.article', $type_dependencies['config'][0]);
    $field_metadata = LingotekConfigMetadata::load('field_config.node.article.body');
    $field_dependencies = $field_metadata
      ->getDependencies();
    $this
      ->assertEqual('field.field.node.article.body', $field_dependencies['config'][0]);
  }

}

Classes

Namesort descending Description
LingotekConfigDependenciesPostUpdateTest Tests the upgrade path for updating the Lingotek metadata config dependencies.