public function UserPictureTest::saveUserPicture in Drupal 8
Same name and namespace in other branches
- 9 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 152
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
->drupalPostForm('user/' . $this->webUser
->id() . '/edit', $edit, t('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);
}