X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fpathauto%2Fsrc%2FTests%2FPathautoEnablingEntityTypesTest.php;fp=web%2Fmodules%2Fcontrib%2Fpathauto%2Fsrc%2FTests%2FPathautoEnablingEntityTypesTest.php;h=c8cc1fff9ae47e78b7f7d15be64af975836792db;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/pathauto/src/Tests/PathautoEnablingEntityTypesTest.php b/web/modules/contrib/pathauto/src/Tests/PathautoEnablingEntityTypesTest.php new file mode 100644 index 000000000..c8cc1fff9 --- /dev/null +++ b/web/modules/contrib/pathauto/src/Tests/PathautoEnablingEntityTypesTest.php @@ -0,0 +1,87 @@ +drupalCreateContentType(array('type' => 'article')); + $this->addDefaultCommentField('node', 'article'); + + $permissions = array( + 'administer pathauto', + 'administer url aliases', + 'create url aliases', + 'administer nodes', + 'post comments', + ); + $this->adminUser = $this->drupalCreateUser($permissions); + $this->drupalLogin($this->adminUser); + } + + /** + * A suite of tests to verify if the feature to enable and disable the + * ability to define alias patterns for a given entity type works. Test with + * the comment module, as it is not enabled by default. + */ + function testEnablingEntityTypes() { + // Verify that the comment entity type is not available when trying to add + // a new pattern, nor "broken". + $this->drupalGet('/admin/config/search/path/patterns/add'); + $this->assertEqual(count($this->cssSelect('option[value = "canonical_entities:comment"]:contains(Comment)')), 0); + $this->assertEqual(count($this->cssSelect('option:contains(Broken)')), 0); + + // Enable the entity type and create a pattern for it. + $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]'); + + // Create a node, a comment type and a comment entity. + $node = $this->drupalCreateNode(['type' => 'article']); + $this->drupalGet('/node/' . $node->id()); + $edit = [ + 'comment_body[0][value]' => 'test-body', + ]; + $this->drupalPostForm(NULL, $edit, 'Save'); + + // Verify that an alias has been generated and that the type can no longer + // be disabled. + $this->assertAliasExists(['alias' => '/comment/test-body']); + $this->drupalGet('/admin/config/search/path/settings'); + $this->assertEqual(count($this->cssSelect('input[name = "enabled_entity_types[comment]"][disabled = "disabled"]')), 1); + } + +}