You are here

public function LingotekProfileFormTest::testAddingProfile in Lingotek Translation 8

Test adding a profile are present.

File

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

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\lingotek\Tests\Form

Code

public function testAddingProfile() {
  $this
    ->drupalGet('admin/lingotek/settings');
  $this
    ->clickLink(t('Add new Translation Profile'));
  $profile_id = strtolower($this
    ->randomMachineName());
  $profile_name = $this
    ->randomString();
  $edit = [
    'id' => $profile_id,
    'label' => $profile_name,
    'auto_upload' => 1,
    'auto_download' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertText(t('The Lingotek profile has been successfully saved.'));

  // We can edit them.
  $this
    ->assertLinkByHref("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $this
    ->assertFieldChecked("edit-profile-{$profile_id}-auto-upload");
  $this
    ->assertFieldChecked("edit-profile-{$profile_id}-auto-download");
  $this
    ->assertFieldEnabled("edit-profile-{$profile_id}-auto-upload");
  $this
    ->assertFieldEnabled("edit-profile-{$profile_id}-auto-download");

  /** @var LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertTrue($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticDownload());
  $this
    ->assertIdentical('default', $profile
    ->getProject());
  $this
    ->assertIdentical('default', $profile
    ->getVault());
  $this
    ->assertIdentical('default', $profile
    ->getWorkflow());
}