You are here

public function DevelSwitchUserTest::testSwitchUserBlockConfiguration in Devel 4.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::testSwitchUserBlockConfiguration()
  2. 8 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::testSwitchUserBlockConfiguration()
  3. 8.2 tests/src/Functional/DevelSwitchUserTest.php \Drupal\Tests\devel\Functional\DevelSwitchUserTest::testSwitchUserBlockConfiguration()

Tests the switch user block configuration.

File

tests/src/Functional/DevelSwitchUserTest.php, line 102

Class

DevelSwitchUserTest
Tests switch user.

Namespace

Drupal\Tests\devel\Functional

Code

public function testSwitchUserBlockConfiguration() {
  $anonymous = \Drupal::config('user.settings')
    ->get('anonymous');

  // Create some users for the test.
  for ($i = 0; $i < 12; $i++) {
    $this
      ->drupalCreateUser();
  }
  $this
    ->drupalLogin($this->develUser);
  $this
    ->drupalGet('');
  $this
    ->assertSession()
    ->pageTextContains($this->block
    ->label(), 'Block title was found.');

  // Ensure that block default configuration is effectively used. The block
  // default configuration is the following:
  // - list_size : 12.
  // - include_anon : FALSE.
  // - show_form : TRUE.
  $this
    ->assertSwitchUserSearchForm();
  $this
    ->assertSwitchUserListCount(12);
  $this
    ->assertSwitchUserListNoContainsUser($anonymous);

  // Ensure that changing the list_size configuration property the number of
  // user displayed in the list change.
  $this
    ->setBlockConfiguration('list_size', 4);
  $this
    ->drupalGet('');
  $this
    ->assertSwitchUserListCount(4);

  // Ensure that changing the include_anon configuration property the
  // anonymous user is displayed in the list.
  $this
    ->setBlockConfiguration('include_anon', TRUE);
  $this
    ->drupalGet('');
  $this
    ->assertSwitchUserListContainsUser($anonymous);

  // Ensure that changing the show_form configuration property the
  // form is not displayed.
  $this
    ->setBlockConfiguration('show_form', FALSE);
  $this
    ->drupalGet('');
  $this
    ->assertSwitchUserNoSearchForm();
}