function UserPictureTest::testUserViewAlter

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::testUserViewAlter()
  2. 10 core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::testUserViewAlter()
  3. 11.x core/modules/user/tests/src/Functional/UserPictureTest.php \Drupal\Tests\user\Functional\UserPictureTest::testUserViewAlter()

Tests user picture field with a non-standard field formatter.

See also

user_user_view_alter()

File

core/modules/user/tests/src/Functional/UserPictureTest.php, line 174

Class

UserPictureTest
Tests user picture functionality.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserViewAlter() {
    \Drupal::service('module_installer')->install([
        'image_module_test',
    ]);
    // Set dummy_image_formatter to the default view mode of user entity.
    EntityViewDisplay::load('user.user.default')->setComponent('user_picture', [
        'region' => 'content',
        'type' => 'dummy_image_formatter',
    ])
        ->save();
    $this->drupalLogin($this->webUser);
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('Dummy');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.