PathautoEnablingEntityTypesTest.php in Pathauto 8
File
tests/src/Functional/PathautoEnablingEntityTypesTest.php
View source
<?php
namespace Drupal\Tests\pathauto\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\comment\Tests\CommentTestTrait;
class PathautoEnablingEntityTypesTest extends BrowserTestBase {
use PathautoTestHelperTrait;
use CommentTestTrait;
protected $defaultTheme = 'stable';
public static $modules = [
'node',
'pathauto',
'comment',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
]);
$this
->addDefaultCommentField('node', 'article');
$permissions = [
'administer pathauto',
'administer url aliases',
'create url aliases',
'administer nodes',
'post comments',
];
$this->adminUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->adminUser);
}
public function testEnablingEntityTypes() {
$this
->drupalGet('/admin/config/search/path/patterns/add');
$this
->assertCount(0, $this
->cssSelect('option[value = "canonical_entities:comment"]:contains(Comment)'));
$this
->assertCount(0, $this
->cssSelect('option:contains(Broken)'));
$this
->drupalGet('/admin/config/search/path/settings');
$edit = [
'enabled_entity_types[comment]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, 'Save configuration');
$this
->createPattern('comment', '/comment/[comment:body]');
$node = $this
->drupalCreateNode([
'type' => 'article',
]);
$this
->drupalGet('/node/' . $node
->id());
$edit = [
'comment_body[0][value]' => 'test-body',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertAliasExists([
'alias' => '/comment/test-body',
]);
$this
->drupalGet('/admin/config/search/path/settings');
$this
->assertCount(1, $this
->cssSelect('input[name = "enabled_entity_types[comment]"][disabled = "disabled"]'));
}
}