function UserPictureTest::testPictureOnNodeComment

Tests embedded users on node pages.

File

drupal/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php, line 98
Definition of Drupal\user\Tests\UserPictureTest.

Class

UserPictureTest
Tests user picture functionality.

Namespace

Drupal\user\Tests

Code

function testPictureOnNodeComment() {
  $this
    ->drupalLogin($this->web_user);

  // Save a new picture.
  $image = current($this
    ->drupalGetTestFiles('image'));
  $file = $this
    ->saveUserPicture($image);
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));

  // Enable user pictures on nodes.
  variable_set('theme_settings', array(
    'toggle_node_user_picture' => TRUE,
  ));

  // Verify that the image is displayed on the user account page.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw(file_uri_target($file->uri), 'User picture found on node page.');

  // Enable user pictures on comments, instead of nodes.
  variable_set('theme_settings', array(
    'toggle_comment_user_picture' => TRUE,
  ));
  $edit = array(
    'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this
      ->randomString(),
  );
  $this
    ->drupalPost('comment/reply/' . $node->nid, $edit, t('Save'));
  $this
    ->assertRaw(file_uri_target($file->uri), 'User picture found on comment.');
}