You are here

public function RenderElementTypesTest::testLingotekSourceStatus in Lingotek Translation 4.0.x

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

Tests #type 'lingotek_source_status'.

File

tests/src/Functional/Render/Element/RenderElementTypesTest.php, line 61

Class

RenderElementTypesTest
Tests the markup of lingotek render element types passed to \Drupal::service('renderer')->render().

Namespace

Drupal\Tests\lingotek\Functional\Render\Element

Code

public function testLingotekSourceStatus() {
  $basepath = \Drupal::request()
    ->getBasePath();

  /** @var \Drupal\node\NodeInterface $entity */
  $entity = Node::create([
    'id' => 1,
    'title' => 'Llamas are cool',
    'type' => 'article',
  ]);
  $entity
    ->save();

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.content_translation');
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_UNTRACKED);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/upload/node/1?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="Upload" class="language-icon source-untracked">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_IMPORTING);
  $translation_service
    ->setDocumentId($entity, 'test-document-id');
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/check_upload/test-document-id?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="Source importing" class="language-icon source-importing">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertNoSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $this
    ->assertSourceAction("Check upload status", "{$basepath}/admin/lingotek/entity/check_upload/test-document-id?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_CURRENT);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<span title="Source uploaded" class="language-icon source-current">EN</span>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertNoSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $this
    ->assertNoSourceAction("Check upload status", "{$basepath}/admin/lingotek/entity/check_upload/test-document-id?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_DISABLED);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<span title="Disabled, cannot request translation" class="language-icon source-disabled">EN</span>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertNoSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_EDITED);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/update/test-document-id?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="Re-upload (content has changed since last upload)" class="language-icon source-edited">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertNoSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $this
    ->assertSourceAction("Update document", "{$basepath}/admin/lingotek/entity/update/test-document-id?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_ERROR);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/update/test-document-id?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="Error" class="language-icon source-error">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertNoSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $this
    ->assertSourceAction("Update document", "{$basepath}/admin/lingotek/entity/update/test-document-id?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setDocumentId($entity, NULL);
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_DELETED);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/upload/node/1?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="This document was deleted in Lingotek. Re-upload to translate." class="language-icon source-deleted">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
  $translation_service
    ->setDocumentId($entity, NULL);
  $translation_service
    ->setSourceStatus($entity, Lingotek::STATUS_ARCHIVED);
  $this
    ->drupalGet('/lingotek_form_test/lingotek_source_status/node/1');
  $this
    ->assertSession()
    ->responseContains('lingotek/css/base.css');
  $this
    ->assertSession()
    ->responseContains('<a href="' . $basepath . '/admin/lingotek/entity/upload/node/1?destination=' . $basepath . '/lingotek_form_test/lingotek_source_status/node/1" title="This document was archived in Lingotek. Re-upload to translate." class="language-icon source-archived">EN</a>');
  $this
    ->assertSourceAction("View", "{$basepath}/node/1");
  $this
    ->assertSourceAction("Upload document", "{$basepath}/admin/lingotek/entity/upload/node/1?destination={$basepath}/lingotek_form_test/lingotek_source_status/node/1");
}