You are here

public function LingotekProfileFormTest::testEditingProfileInListing in Lingotek Translation 3.6.x

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

Test editing profiles auto properties in the listing.

File

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

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testEditingProfileInListing() {

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();
  $this
    ->drupalGet("/admin/lingotek/settings");
  $edit = [
    "profile[{$profile_id}][auto_upload]" => 1,
    "profile[{$profile_id}][auto_request]" => 0,
    "profile[{$profile_id}][auto_download]" => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration', [], 'lingotek-profile-admin-overview-form');

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertTrue($profile
    ->hasAutomaticUpload());
  $this
    ->assertFalse($profile
    ->hasAutomaticRequest());
  $this
    ->assertTrue($profile
    ->hasAutomaticDownload());
  $this
    ->assertFieldChecked("profile[{$profile_id}][auto_upload]");
  $this
    ->assertNoFieldChecked("profile[{$profile_id}][auto_request]");
  $this
    ->assertFieldChecked("profile[{$profile_id}][auto_download]");
  $edit = [
    "profile[{$profile_id}][auto_upload]" => 1,
    "profile[{$profile_id}][auto_request]" => 1,
    "profile[{$profile_id}][auto_download]" => 0,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration', [], 'lingotek-profile-admin-overview-form');

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertTrue($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticRequest());
  $this
    ->assertFalse($profile
    ->hasAutomaticDownload());
  $this
    ->assertFieldChecked("profile[{$profile_id}][auto_upload]");
  $this
    ->assertFieldChecked("profile[{$profile_id}][auto_request]");
  $this
    ->assertNoFieldChecked("profile[{$profile_id}][auto_download]");
  $edit = [
    "profile[{$profile_id}][auto_upload]" => 0,
    "profile[{$profile_id}][auto_request]" => 1,
    "profile[{$profile_id}][auto_download]" => 0,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration', [], 'lingotek-profile-admin-overview-form');

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertFalse($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticRequest());
  $this
    ->assertFalse($profile
    ->hasAutomaticDownload());
  $this
    ->assertNoFieldChecked("profile[{$profile_id}][auto_upload]");
  $this
    ->assertFieldChecked("profile[{$profile_id}][auto_request]");
  $this
    ->assertNoFieldChecked("profile[{$profile_id}][auto_download]");
}