You are here

function UserPictureTest::saveUserPicture in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/UserPictureTest.php \Drupal\user\Tests\UserPictureTest::saveUserPicture()

Edits the user picture for the test user.

2 calls to UserPictureTest::saveUserPicture()
UserPictureTest::testCreateDeletePicture in core/modules/user/src/Tests/UserPictureTest.php
Tests creation, display, and deletion of user pictures.
UserPictureTest::testPictureOnNodeComment in core/modules/user/src/Tests/UserPictureTest.php
Tests embedded users on node pages.

File

core/modules/user/src/Tests/UserPictureTest.php, line 137
Contains \Drupal\user\Tests\UserPictureTest.

Class

UserPictureTest
Tests user picture functionality.

Namespace

Drupal\user\Tests

Code

function saveUserPicture($image) {
  $edit = array(
    'files[user_picture_0]' => drupal_realpath($image->uri),
  );
  $this
    ->drupalPostForm('user/' . $this->webUser
    ->id() . '/edit', $edit, t('Save'));

  // Load actual user data from database.
  $user_storage = $this->container
    ->get('entity.manager')
    ->getStorage('user');
  $user_storage
    ->resetCache(array(
    $this->webUser
      ->id(),
  ));
  $account = $user_storage
    ->load($this->webUser
    ->id());
  return File::load($account->user_picture->target_id);
}