function ShareMessageSettingsTest::testShareMessageDeleteCancel in Share Message 8
Tests the Share Message delete and cancel button functionality.
File
- tests/
src/ Functional/ ShareMessageSettingsTest.php, line 234
Class
- ShareMessageSettingsTest
- Check if default Share Message settings work correctly.
Namespace
Drupal\Tests\sharemessage\FunctionalCode
function testShareMessageDeleteCancel() {
// Create a Share Message.
$this
->drupalGet('admin/config/services/sharemessage/add');
$sharemessage = [
'label' => 'Share Message Test Label',
'id' => 'sharemessage_test_label',
'settings[override_default_settings]' => 1,
'settings[services][]' => [
'facebook',
],
'settings[additional_services]' => 1,
'settings[icon_style]' => 'addthis_32x32_style',
];
$this
->drupalPostForm(NULL, $sharemessage, t('Save'));
// Check newly created Share Message on list page.
$this
->drupalGet('admin/config/services/sharemessage');
$this
->assertText($sharemessage['label'], 'Newly created sharemessage found.');
// Check for Edit link.
$this
->assertLink('Edit');
// Check for the Delete link.
$this
->assertLink('Delete');
// Click delete link on admin ui.
$this
->clickLink('Delete');
$this
->assertText(t('Are you sure you want to delete the share message @label?', [
'@label' => $sharemessage['label'],
]));
// Check if cancel button is present or not.
$this
->assertLink('Cancel');
// Delete the Share Message.
$this
->drupalPostForm(NULL, [], t('Delete'));
$this
->assertText(t('The share message @label has been deleted.', [
'@label' => $sharemessage['label'],
]));
// Check if removed from listing page as well.
$this
->drupalGet('admin/config/services/sharemessage');
$this
->assertNoText($sharemessage['label'], 'Not found the deleted message.');
}