You are here

public function LingotekSystemSiteBulkDisassociateTest::testSystemSiteDisassociate in Lingotek Translation 8

Tests that a config entity can be disassociated using the bulk operations on the management page.

File

src/Tests/LingotekSystemSiteBulkDisassociateTest.php, line 33

Class

LingotekSystemSiteBulkDisassociateTest
Tests translating config using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testSystemSiteDisassociate() {

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'system.site');

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->createAndTranslateSystemSiteWithLinks();

  // Go to the bulk config management page.
  $this
    ->goToConfigBulkManagementForm();

  // Mark the first two for disassociation.
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    // System information.
    'operation' => 'disassociate',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));

  /** @var LingotekConfigTranslationServiceInterface $config_translation_service */
  $config_translation_service = \Drupal::service('lingotek.config_translation');
  $mappers = \Drupal::service('plugin.manager.config_translation.mapper')
    ->getMappers();
  $mapper = $mappers['system.site_information_settings'];

  // Assert that no document has been deleted remotely.
  $deleted_docs = \Drupal::state()
    ->get('lingotek.deleted_docs', []);
  $this
    ->assertEqual(0, count($deleted_docs), 'No document has been deleted remotely because the module is not configured to perform the operation.');
  $this
    ->assertNull($config_translation_service
    ->getConfigDocumentId($mapper));
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $config_translation_service
    ->getConfigSourceStatus($mapper));

  // We can request again.
  $this
    ->createAndTranslateSystemSiteWithLinks();
}