diff --git a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php index c04b939..763d106 100644 --- a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php @@ -110,7 +110,6 @@ public function testCacheTags() { 'comment_view', 'comment:' . $comment->id(), 'config:filter.format.plain_text', - 'config:user.settings', 'user_view', 'user:2', ); diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 6b2abcc..fd7f716 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -494,20 +494,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->addConstraint('UserMailUnique') ->addConstraint('UserMailRequired'); - // @todo Convert to a text field in https://drupal.org/node/1548204. - $fields['signature'] = BaseFieldDefinition::create('string') - ->setLabel(t('Signature')) - ->setDescription(t('The signature of this user.')) - ->setTranslatable(TRUE); - $fields['signature_format'] = BaseFieldDefinition::create('string') - ->setLabel(t('Signature format')) - ->setDescription(t('The signature format of this user.')) - // @todo: Define this via an options provider once - // https://www.drupal.org/node/2329937 is completed. - ->addPropertyConstraints('value', array( - 'AllowedValues' => array('callback' => __CLASS__ . '::getAllowedSignatureFormats'), - )); - $fields['timezone'] = BaseFieldDefinition::create('string') ->setLabel(t('Timezone')) ->setDescription(t('The timezone of this user.')) @@ -566,20 +552,6 @@ protected function getRoleStorage() { } /** - * Defines allowed signature formats for the field's AllowedValues constraint. - * - * @return string[] - * The allowed values. - */ - public static function getAllowedSignatureFormats() { - if (\Drupal::moduleHandler()->moduleExists('filter')) { - return array_keys(filter_formats()); - } - // If filter.module is disabled, no value may be assigned. - return array(); - } - - /** * Defines allowed timezones for the field's AllowedValues constraint. * * @return string[] diff --git a/core/modules/user/src/Tests/UserSignatureTest.php b/core/modules/user/src/Tests/UserSignatureTest.php deleted file mode 100644 index 47b1636..0000000 --- a/core/modules/user/src/Tests/UserSignatureTest.php +++ /dev/null @@ -1,174 +0,0 @@ -config('user.settings')->set('signatures', 1)->save(); - - // Create Basic page node type. - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - // Add a comment field with commenting enabled by default. - $this->addDefaultCommentField('node', 'page'); - - // Prefetch and create text formats. - $this->filteredHtmlFormat = entity_create('filter_format', array( - 'format' => 'filtered_html_format', - 'name' => 'Filtered HTML', - 'weight' => -1, - 'filters' => array( - 'filter_html' => array( - 'module' => 'filter', - 'status' => TRUE, - 'settings' => array( - 'allowed_html' => ' ', - ), - ), - ), - )); - $this->filteredHtmlFormat->save(); - - $this->fullHtmlFormat = entity_create('filter_format', array( - 'format' => 'full_html', - 'name' => 'Full HTML', - )); - $this->fullHtmlFormat->save(); - - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array($this->filteredHtmlFormat->getPermissionName())); - - // Create regular and administrative users. - $this->webUser = $this->drupalCreateUser(array('post comments')); - - $admin_permissions = array('post comments', 'administer comments', 'administer user form display', 'administer account settings'); - foreach (filter_formats() as $format) { - if ($permission = $format->getPermissionName()) { - $admin_permissions[] = $permission; - } - } - $this->adminUser = $this->drupalCreateUser($admin_permissions); - } - - /** - * Test that a user can change their signature format and that it is respected - * upon display. - */ - function testUserSignature() { - $node = $this->drupalCreateNode(array( - 'body' => array( - 0 => array( - 'value' => $this->randomMachineName(32), - 'format' => 'full_html', - ), - ), - )); - - // Verify that user signature field is not displayed on registration form. - $this->drupalGet('user/register'); - $this->assertNoText(t('Signature')); - - // Log in as a regular user and create a signature. - $this->drupalLogin($this->webUser); - $signature_text = "

" . $this->randomMachineName() . "

"; - $edit = array( - 'signature[value]' => $signature_text, - ); - $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save')); - - // Verify that values were stored. - $this->assertFieldByName('signature[value]', $edit['signature[value]'], 'Submitted signature text found.'); - - // Verify that the user signature's text format's cache tag is absent. - $this->drupalGet('node/' . $node->id()); - $this->assertTrue(!in_array('filter_format:filtered_html_format', explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')))); - - // Create a comment. - $edit = array(); - $edit['subject[0][value]'] = $this->randomMachineName(8); - $edit['comment_body[0][value]'] = $this->randomMachineName(16); - $this->drupalPostForm('comment/reply/node/' . $node->id() .'/comment', $edit, t('Preview')); - $this->drupalPostForm(NULL, array(), t('Save')); - - // Get the comment ID. (This technique is the same one used in the Comment - // module's CommentTestBase test case.) - preg_match('/#comment-([0-9]+)/', $this->getURL(), $match); - $comment_id = $match[1]; - - // Log in as an administrator and edit the comment to use Full HTML, so - // that the comment text itself is not filtered at all. - $this->drupalLogin($this->adminUser); - $edit['comment_body[0][format]'] = $this->fullHtmlFormat->id(); - $this->drupalPostForm('comment/' . $comment_id . '/edit', $edit, t('Save')); - - // Assert that the signature did not make it through unfiltered. - $this->drupalGet('node/' . $node->id()); - $this->assertNoRaw($signature_text, 'Unfiltered signature text not found.'); - $this->assertRaw(check_markup($signature_text, $this->filteredHtmlFormat->id()), 'Filtered signature text found.'); - // Verify that the user signature's text format's cache tag is present. - $this->drupalGet('node/' . $node->id()); - $this->assertTrue(in_array('config:filter.format.filtered_html_format', explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')))); - - // Verify the signature field is available on Manage form display page. - $this->config('user.settings')->set('signatures', 0)->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); - $this->drupalGet('admin/config/people/accounts/form-display'); - $this->assertNoText('Signature settings'); - $this->drupalPostForm('admin/config/people/accounts', array('user_signatures' => TRUE), t('Save configuration')); - $this->drupalGet('admin/config/people/accounts/form-display'); - $this->assertText('Signature settings'); - } -}