public function PerCommentTypeSettingsTest::testSettingSaving in Simplify 8
Check that Simplify module global configuration files saves settings.
File
- src/
Tests/ PerCommentTypeSettingsTest.php, line 74
Class
- PerCommentTypeSettingsTest
- Test simplify per comment-type settings.
Namespace
Drupal\simplify\TestsCode
public function testSettingSaving() {
/* -------------------------------------------------------.
* 0/ Check the comment form by default.
*/
// Create a test node authored by the user.
$node = $this
->drupalCreateNode([
'type' => 'content_type',
'promote' => 1,
'uid' => $this->adminUser
->id(),
]);
// Check if options are there.
$this
->drupalGet("/node/" . $node
->id());
$this
->assertRaw('About text formats', 'Comment text format option is defined.');
/* -------------------------------------------------------.
* 1/ Activate some global options and check "per comment-type" accordingly.
*/
// Globally activate some options.
$this
->drupalGet('/admin/config/user-interface/simplify');
$options = [
'simplify_admin' => TRUE,
'simplify_comments_global[format]' => 'format',
];
$this
->drupalPostForm(NULL, $options, $this
->t('Save configuration'));
// Open admin UI.
$this
->drupalGet('/admin/structure/comment/manage/comment');
// Check if global options are forwarded.
$this
->assertFieldChecked('edit-simplify-comments-format', 'Comment text fomat selection option is checked.');
// Check if everything is properly disabled if needed.
$text_format = $this
->xpath('//input[@name="simplify_comments[format]" and @disabled="disabled"]');
$this
->assertTrue(count($text_format) === 1, 'Comment text format option is disabled.');
/* -------------------------------------------------------.
* 2/ Remove global options.
*/
$this
->drupalGet('/admin/config/user-interface/simplify');
$options = [
'simplify_admin' => TRUE,
'simplify_comments_global[format]' => FALSE,
];
$this
->drupalPostForm(NULL, $options, $this
->t('Save configuration'));
// Open admin UI.
$this
->drupalGet('/admin/structure/comment/manage/comment');
// Check if global options are forwarded.
$this
->assertNoFieldChecked('edit-simplify-comments-format', 'Comment text fomat selection option is not checked.');
/* -------------------------------------------------------.
* 3/ Save some custom options.
*/
// Nodes.
$options = [
'simplify_comments[format]' => 'format',
];
$this
->drupalPostForm(NULL, $options, $this
->t('Save'));
/* -------------------------------------------------------.
* 4/ Check if options are saved.
*/
$this
->drupalGet('/admin/structure/comment/manage/comment');
$this
->assertFieldChecked('edit-simplify-comments-format', 'Comment text fomat selection option is checked.');
/*
* 5/ Check if comment form is now simplified.
*/
$this
->drupalGet("/node/" . $node
->id());
$this
->assertNoRaw('About text formats', 'Comment text format option is not defined.');
}