You are here

public function DefaultUserImageTest::testAlreadyExists in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/DefaultUserImageTest.php \Drupal\Tests\lightning_core\Kernel\DefaultUserImageTest::testAlreadyExists()
  2. 8.4 tests/src/Kernel/DefaultUserImageTest.php \Drupal\Tests\lightning_core\Kernel\DefaultUserImageTest::testAlreadyExists()

Tests that the default avatar is not set if the image already exists.

File

tests/src/Kernel/DefaultUserImageTest.php, line 43

Class

DefaultUserImageTest
@group lightning_core

Namespace

Drupal\Tests\lightning_core\Kernel

Code

public function testAlreadyExists() {
  file_put_contents('public://default-avatar.png', '');
  \Drupal::service('module_installer')
    ->install([
    'lightning_core',
    'image',
  ]);
  $this
    ->assertEmpty(File::loadMultiple());
  $config = FieldConfig::load('user.user.user_picture');
  $setting = $config
    ->getSetting('default_image');
  $this
    ->assertNull($setting['uuid']);
  $this
    ->assertSame('', $setting['alt']);
  $this
    ->assertSame('', $setting['title']);
  $this
    ->assertNull($setting['width']);
  $this
    ->assertNull($setting['height']);
}