function UserPictureTest::saveUserPicture
Same name in other branches
- 9 core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::saveUserPicture()
- 8.9.x core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::saveUserPicture()
- 10 core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::saveUserPicture()
Edits the user picture for the test user.
2 calls to UserPictureTest::saveUserPicture()
- UserPictureTest::testCreateDeletePicture in core/
modules/ user/ tests/ src/ Functional/ UserPictureTest.php - Tests creation, display, and deletion of user pictures.
- UserPictureTest::testPictureOnNodeComment in core/
modules/ user/ tests/ src/ Functional/ UserPictureTest.php - Tests embedded users on node pages.
File
-
core/
modules/ user/ tests/ src/ Functional/ UserPictureTest.php, line 163
Class
- UserPictureTest
- Tests user picture functionality.
Namespace
Drupal\Tests\user\FunctionalCode
public function saveUserPicture($image) {
$edit = [
'files[user_picture_0]' => \Drupal::service('file_system')->realpath($image->uri),
];
$this->drupalGet('user/' . $this->webUser
->id() . '/edit');
$this->submitForm($edit, 'Save');
// Load actual user data from database.
$user_storage = $this->container
->get('entity_type.manager')
->getStorage('user');
$user_storage->resetCache([
$this->webUser
->id(),
]);
$account = $user_storage->load($this->webUser
->id());
return File::load($account->user_picture->target_id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.