diff --git a/core/modules/contact/lib/Drupal/contact/CategoryListController.php b/core/modules/contact/lib/Drupal/contact/CategoryListController.php index 3bb0505..8a0bb02 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryListController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php @@ -60,9 +60,16 @@ public function buildHeader() { */ public function buildRow(EntityInterface $entity) { $row['category'] = check_plain($entity->label()); - $row['recipients'] = check_plain(implode(', ', $entity->recipients)); - $default_category = config('contact.settings')->get('default_category'); - $row['selected'] = ($default_category == $entity->id() ? t('Yes') : t('No')); + // Special case the personal category. + if ($entity->id() == 'personal') { + $row['recipients'] = t('Selected user'); + $row['selected'] = t('No'); + } + else { + $row['recipients'] = check_plain(implode(', ', $entity->recipients)); + $default_category = config('contact.settings')->get('default_category'); + $row['selected'] = ($default_category == $entity->id() ? t('Yes') : t('No')); + } $row['operations']['data'] = $this->buildOperations($entity); return $row; } diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php index bb7d7d4..026b169 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php @@ -63,6 +63,22 @@ function setUp() { } /** + * Tests that mails for contact messages are correctly sent. + */ + function testSendPersonalContactMessage() { + $this->drupalLogin($this->web_user); + + $message = $this->submitPersonalContact($this->contact_user); + $mails = $this->drupalGetMails(); + $this->assertEqual(1, count($mails)); + $mail = $mails[0]; + $this->assertEqual($mail['to'], $this->contact_user->mail); + $this->assertEqual($mail['from'], $this->web_user->mail); + $this->assertTrue(strpos($mail['subject'], $message['subject']) !== FALSE, 'Subject is in sent message.'); + $this->assertTrue(strpos($mail['body'], $message['message']) !== FALSE, 'Subject is in sent message.'); + } + + /** * Tests access to the personal contact form. */ function testPersonalContactAccess() { @@ -188,5 +204,6 @@ protected function submitPersonalContact($account, array $message = array()) { 'message' => $this->randomName(64), ); $this->drupalPost('user/' . $account->uid . '/contact', $message, t('Send message')); + return $message; } } diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index b0e46bf..9c15ba1 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -57,7 +57,7 @@ function testSiteWideContact() { // Delete old categories to ensure that new categories are used. $this->deleteCategories(); $this->drupalGet('admin/structure/contact'); - $this->assertLinkByHref('admin/structure/contact/manage/personal'); + $this->assertText('Personal', 'Personal category was not deleted'); $this->assertNoLinkByHref('admin/structure/contact/manage/feedback'); // Ensure that the contact form won't be shown without categories.