You are here

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

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

Test deleting profile being used in content is not deleted.

File

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

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testDeletingProfileBeingUsedInConfigSettings() {

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();

  // Create Article node types.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Go to the bulk config management page.
  $this
    ->goToConfigBulkManagementForm('node_type');
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'change_profile:' . $profile_id,
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/delete");

  // Confirm the form.
  $this
    ->assertText(t('This action cannot be undone.'));
  $this
    ->drupalPostForm(NULL, [], t('Delete'));
  $this
    ->assertNoRaw(t('The lingotek profile %profile has been deleted.', [
    '%profile' => $profile
      ->label(),
  ]));
  $this
    ->assertRaw(t('The Lingotek profile %profile is being used so cannot be deleted.', [
    '%profile' => $profile
      ->label(),
  ]));

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertNotNull($profile);
}