You are here

public function LingotekSystemSiteBulkCancelTest::testSystemSiteCancelTarget in Lingotek Translation 3.0.x

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

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

File

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

Class

LingotekSystemSiteBulkCancelTest
Tests translating config using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testSystemSiteCancelTarget() {
  $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:es',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  /** @var \Drupal\lingotek\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 the document target has been cancelled remotely.
  $cancelled_locales = \Drupal::state()
    ->get('lingotek.cancelled_locales', []);
  $this
    ->assertTrue(isset($cancelled_locales['dummy-document-hash-id']) && in_array('es_ES', $cancelled_locales['dummy-document-hash-id']), 'The document target has been cancelled remotely.');
  $this
    ->assertEquals('dummy-document-hash-id', $config_translation_service
    ->getConfigDocumentId($mapper));
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
  $this
    ->assertIdentical(Lingotek::STATUS_CURRENT, $config_translation_service
    ->getConfigSourceStatus($mapper));
  $this
    ->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
    ->getConfigTargetStatus($mapper, 'es'));

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