You are here

public function LingotekMetadataEditFormTest::testMetadataEditFormWithoutEnablingBundle in Lingotek Translation 3.7.x

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

Tests that if debug is not enabled, metadata tab is not available.

File

tests/src/Functional/Form/LingotekMetadataEditFormTest.php, line 282

Class

LingotekMetadataEditFormTest
Tests the Lingotek metadata form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // Enable debug operations.
  $this
    ->drupalPostForm('admin/lingotek/settings', [], 'Enable debug operations');

  // Create a node.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $this
    ->saveAndPublishNodeForm($edit, 'page');

  // The metadata local task should be visible.
  $this
    ->drupalGet('/node/1');
  $this
    ->clickLink(t('Lingotek Metadata'));
  $this
    ->assertUrl('/node/1/metadata', [], 'Metadata local task enables the metadata form.');

  // Assert that the values are defaults.
  $this
    ->assertFieldById('edit-lingotek-document-id', '');
  $assert_session
    ->optionExists('edit-lingotek-source-status', Lingotek::STATUS_UNTRACKED);
  $assert_session
    ->optionExists('edit-en', Lingotek::STATUS_UNTRACKED);
  $assert_session
    ->optionExists('edit-es', Lingotek::STATUS_UNTRACKED);
  $this
    ->assertFieldById('edit-lingotek-job-id', '');
  $this
    ->assertFieldByName('verbatim_area[verbatim]', 'NULL');
  $edit = [
    'lingotek_document_id' => 'another-id',
    'lingotek_source_status' => Lingotek::STATUS_UNTRACKED,
    'en' => Lingotek::STATUS_UNTRACKED,
    'es' => Lingotek::STATUS_READY,
    'lingotek_job_id' => 'a new edited job id',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save metadata');
  $assert_session
    ->pageTextNotContains('Metadata saved successfully');
  $assert_session
    ->pageTextContains('This entity cannot be managed in Lingotek. Please check your configuration.');
}