MailhandlerCommentWebTest.php in Mailhandler 8
File
mailhandler_comment/src/Tests/MailhandlerCommentWebTest.php
View source
<?php
namespace Drupal\mailhandler_comment\Tests;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
class MailhandlerCommentWebTest extends WebTestBase {
use CommentTestTrait;
public static $modules = [
'mailhandler_comment',
'block',
'field_ui',
];
public function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
$this
->drupalPlaceBlock('local_actions_block');
$this
->drupalPlaceBlock('page_title_block');
$this->blog = NodeType::create([
'type' => 'blog',
'name' => 'Blog',
]);
$this->blog
->save();
$this
->addDefaultCommentField('node', 'blog');
$this->user = $this
->drupalCreateUser([
'access administration pages',
'administer inmail',
'administer user form display',
'administer content types',
'administer user display',
]);
$this
->drupalLogin($this->user);
}
protected function testMailhandlerCommentUi() {
$this
->drupalGet('admin/config/system/inmail/handlers');
$this
->assertText(t('Post comments via email'));
$this
->assertText(t('Comment'));
$mailhandler_comment_path = 'admin/config/system/inmail/handlers/mailhandler_comment';
$this
->drupalGet($mailhandler_comment_path);
$this
->assertText(t('Post comments via email'));
$this
->assertText('mailhandler_comment');
$this
->assertText(t('Select a referenced entity type.'));
$comment_entity_types = (array) $this
->xpath('//*[@id="edit-entity-type"]')[0]->option;
$this
->assertTrue(in_array('Content', $comment_entity_types));
}
}