3 namespace Drupal\pathauto\Tests;
5 use Drupal\simpletest\WebTestBase;
6 use Drupal\comment\Tests\CommentTestTrait;
9 * Tests pathauto settings form.
13 class PathautoEnablingEntityTypesTest extends WebTestBase {
15 use PathautoTestHelperTrait;
24 public static $modules = array('node', 'pathauto', 'comment');
29 * @var \Drupal\user\UserInterface
39 $this->drupalCreateContentType(array('type' => 'article'));
40 $this->addDefaultCommentField('node', 'article');
43 'administer pathauto',
44 'administer url aliases',
49 $this->adminUser = $this->drupalCreateUser($permissions);
50 $this->drupalLogin($this->adminUser);
54 * A suite of tests to verify if the feature to enable and disable the
55 * ability to define alias patterns for a given entity type works. Test with
56 * the comment module, as it is not enabled by default.
58 function testEnablingEntityTypes() {
59 // Verify that the comment entity type is not available when trying to add
60 // a new pattern, nor "broken".
61 $this->drupalGet('/admin/config/search/path/patterns/add');
62 $this->assertEqual(count($this->cssSelect('option[value = "canonical_entities:comment"]:contains(Comment)')), 0);
63 $this->assertEqual(count($this->cssSelect('option:contains(Broken)')), 0);
65 // Enable the entity type and create a pattern for it.
66 $this->drupalGet('/admin/config/search/path/settings');
68 'enabled_entity_types[comment]' => TRUE,
70 $this->drupalPostForm(NULL, $edit, 'Save configuration');
71 $this->createPattern('comment', '/comment/[comment:body]');
73 // Create a node, a comment type and a comment entity.
74 $node = $this->drupalCreateNode(['type' => 'article']);
75 $this->drupalGet('/node/' . $node->id());
77 'comment_body[0][value]' => 'test-body',
79 $this->drupalPostForm(NULL, $edit, 'Save');
81 // Verify that an alias has been generated and that the type can no longer
83 $this->assertAliasExists(['alias' => '/comment/test-body']);
84 $this->drupalGet('/admin/config/search/path/settings');
85 $this->assertEqual(count($this->cssSelect('input[name = "enabled_entity_types[comment]"][disabled = "disabled"]')), 1);