You are here

public function LingotekProfileFormTest::testEditingProfile in Lingotek Translation 8

Test editing profiles.

File

src/Tests/Form/LingotekProfileFormTest.php, line 93

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\lingotek\Tests\Form

Code

public function testEditingProfile() {

  /** @var LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();
  $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',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  /** @var LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertFalse($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticDownload());
  $this
    ->assertIdentical('test_project', $profile
    ->getProject());
  $this
    ->assertIdentical('test_vault', $profile
    ->getVault());
  $this
    ->assertIdentical('test_workflow', $profile
    ->getWorkflow());
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertNoFieldChecked("edit-auto-upload");
  $this
    ->assertFieldChecked("edit-auto-download");
  $this
    ->assertOptionSelected('edit-project', 'test_project');
  $this
    ->assertOptionSelected('edit-vault', 'test_vault');
  $this
    ->assertOptionSelected('edit-workflow', 'test_workflow');
}