You are here

public function LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation in Lingotek Translation 3.3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  2. 4.0.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  3. 3.0.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  4. 3.1.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  5. 3.2.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  6. 3.4.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  7. 3.5.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  8. 3.6.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  9. 3.7.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()
  10. 3.8.x tests/src/Functional/LingotekSystemSiteBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekSystemSiteBulkCancelTest::testSystemSiteCancellation()

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

File

tests/src/Functional/LingotekSystemSiteBulkCancelTest.php, line 32

Class

LingotekSystemSiteBulkCancelTest
Tests translating config using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testSystemSiteCancellation() {
  $assert_session = $this
    ->assertSession();

  // 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 for cancelling.
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'cancel',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  /** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
  $config_translation_service = \Drupal::service('lingotek.config_translation');

  // Assert that The document has been cancelled remotely.
  $cancelled_docs = \Drupal::state()
    ->get('lingotek.cancelled_docs', []);
  $this
    ->assertEqual(1, count($cancelled_docs), 'The document has been cancelled remotely.');

  // 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.');
  $mappers = \Drupal::service('plugin.manager.config_translation.mapper')
    ->getMappers();
  $mapper = $mappers['system.site_information_settings'];
  $this
    ->assertNull($config_translation_service
    ->getConfigDocumentId($mapper));
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
    ->getConfigSourceStatus($mapper));
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
    ->getConfigTargetStatus($mapper, 'es'));

  // We can request again.
  $basepath = \Drupal::request()
    ->getBasePath();
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->createAndTranslateSystemSiteWithLinks();
}