public function LingotekProfileFormTest::testDeletingProfileBeingUsedInContentSettings in Lingotek Translation 8
Test deleting profile being configured for usage in content is not deleted.
File
- src/
Tests/ Form/ LingotekProfileFormTest.php, line 244
Class
- LingotekProfileFormTest
- Tests the Lingotek profile form.
Namespace
Drupal\lingotek\Tests\FormCode
public function testDeletingProfileBeingUsedInContentSettings() {
/** @var 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);
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => $profile_id,
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
];
$this
->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-content-form');
$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 LingotekProfileInterface $profile */
$profile = LingotekProfile::load($profile_id);
$this
->assertNotNull($profile);
}