public function LingotekContentTypeBulkCancelTest::testContentTypeCancel in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 4.0.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.0.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.1.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.2.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.3.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.5.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.6.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.7.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
- 3.8.x tests/src/Functional/LingotekContentTypeBulkCancelTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkCancelTest::testContentTypeCancel()
Tests that a config entity can be cancelled using the bulk operations on the management page.
File
- tests/
src/ Functional/ LingotekContentTypeBulkCancelTest.php, line 43
Class
- LingotekContentTypeBulkCancelTest
- Tests cancelling config entities using the bulk management form.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testContentTypeCancel() {
$assert_session = $this
->assertSession();
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'content_type');
// Login as admin.
$this
->drupalLogin($this->rootUser);
$this
->createAndTranslateContentTypeWithLinks();
// Mark the first for cancelling.
$edit = [
'table[article]' => 'article',
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancel('node_type'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
/** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
$config_translation_service = \Drupal::service('lingotek.config_translation');
\Drupal::entityTypeManager()
->getStorage('node_type')
->resetCache();
// 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.');
\Drupal::entityTypeManager()
->getStorage('node_type')
->resetCache();
$entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->load('article');
$this
->assertNull($config_translation_service
->getDocumentId($entity));
$this
->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
$this
->assertTargetStatus('ES', Lingotek::STATUS_CANCELLED);
$this
->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
->getSourceStatus($entity));
$this
->assertIdentical(Lingotek::STATUS_CANCELLED, $config_translation_service
->getTargetStatus($entity, 'es'));
// We can request again.
$basepath = \Drupal::request()
->getBasePath();
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->createAndTranslateContentTypeWithLinks();
}