function WhoIsOnlineBlockTest::setUp
Overrides KernelTestBase::setUp
File
- 
              core/
modules/ user/ tests/ src/ Kernel/ WhoIsOnlineBlockTest.php, line 49  
Class
- WhoIsOnlineBlockTest
 - Tests the Who's Online Block.
 
Namespace
Drupal\Tests\user\KernelCode
protected function setUp() : void {
  parent::setUp();
  $this->container
    ->get('theme_installer')
    ->install([
    'stark',
  ]);
  $this->installConfig([
    'system',
    'block',
    'views',
    'user',
  ]);
  $this->installEntitySchema('user');
  $this->controller = $this->container
    ->get('entity_type.manager')
    ->getStorage('block');
  // Create a block with only required values.
  $this->block = $this->controller
    ->create([
    'plugin' => 'views_block:who_s_online-who_s_online_block',
    'region' => 'sidebar_first',
    'id' => 'views_block__who_s_online_who_s_online_block',
    'theme' => \Drupal::configFactory()->get('system.theme')
      ->get('default'),
    'label' => "Who's online",
    'visibility' => [],
    'weight' => 0,
  ]);
  $this->block
    ->save();
  $this->container
    ->get('cache.render')
    ->deleteAll();
  $this->renderer = $this->container
    ->get('renderer');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.