You are here

public function LingotekProfileFormTest::testEditingProfile in Lingotek Translation 3.5.x

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

Test editing profiles.

File

tests/src/Functional/Form/LingotekProfileFormTest.php, line 136

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();
  $this
    ->assertIdentical('global_setting', $profile
    ->getAppendContentTypeToTitle());
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $edit = [
    'auto_upload' => FALSE,
    'auto_download' => 1,
    'project' => 'test_project',
    'vault' => 'test_vault',
    'workflow' => 'test_workflow',
    'filter' => 'test_filter',
    'subfilter' => 'test_filter2',
    'append_type_to_title' => 'no',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertFalse($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticDownload());
  $this
    ->assertIdentical('no', $profile
    ->getAppendContentTypeToTitle());
  $this
    ->assertIdentical('test_project', $profile
    ->getProject());
  $this
    ->assertIdentical('test_vault', $profile
    ->getVault());
  $this
    ->assertIdentical('test_workflow', $profile
    ->getWorkflow());
  $this
    ->assertIdentical('test_filter', $profile
    ->getFilter());
  $this
    ->assertIdentical('test_filter2', $profile
    ->getSubfilter());
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertNoFieldChecked("edit-auto-upload");
  $this
    ->assertFieldChecked("edit-auto-download");
  $assert_session
    ->optionExists('edit-append-type-to-title', 'no');
  $assert_session
    ->optionExists('edit-project', 'test_project');
  $assert_session
    ->optionExists('edit-vault', 'test_vault');
  $assert_session
    ->optionExists('edit-workflow', 'test_workflow');
  $assert_session
    ->optionExists('edit-filter', 'test_filter');
  $assert_session
    ->optionExists('edit-subfilter', 'test_filter2');
}