public function LingotekProfileFormTest::testDeletingProfileBeingUsedInContent in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 4.0.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.0.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.1.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.2.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.3.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.5.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.6.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.7.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
- 3.8.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testDeletingProfileBeingUsedInContent()
Test deleting profile being used in content is not deleted.
File
- tests/
src/ Functional/ Form/ LingotekProfileFormTest.php, line 276
Class
- LingotekProfileFormTest
- Tests the Lingotek profile form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testDeletingProfileBeingUsedInContent() {
/** @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',
]);
// Enable translation for the current entity type and ensure the change is
// picked up.
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
$this
->saveLingotekContentTranslationSettingsForNodeTypes();
// Create a node.
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = $profile_id;
$this
->saveAndPublishNodeForm($edit);
$this
->assertUrl('/node/1', [], 'Node has been created.');
$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);
}