You are here

class MemberCountBlockTest in Organic groups 8

Tests the member count block.

@group og

Hierarchy

Expanded class hierarchy of MemberCountBlockTest

File

tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php, line 22

Namespace

Drupal\Tests\og\Kernel\Plugin\Block
View source
class MemberCountBlockTest extends KernelTestBase {
  use OgMembershipCreationTrait;
  use StringTranslationTrait;
  use UserCreationTrait;

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'block',
    'entity_test',
    'field',
    'og',
    'system',
    'user',
  ];

  /**
   * The group type manager.
   *
   * @var \Drupal\og\GroupTypeManagerInterface
   */
  protected $groupTypeManager;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The block storage handler.
   *
   * @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface
   */
  protected $blockStorage;

  /**
   * The block view builder.
   *
   * @var \Drupal\Core\Entity\EntityViewBuilderInterface
   */
  protected $blockViewBuilder;

  /**
   * The cache tags invalidator.
   *
   * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
   */
  protected $cacheTagsInvalidator;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * The render cache.
   *
   * @var \Drupal\Core\Render\PlaceholderingRenderCache
   */
  protected $renderCache;

  /**
   * Test groups.
   *
   * @var \Drupal\entity_test\Entity\EntityTest[]
   */
  protected $groups;

  /**
   * A test block. This is the system under test.
   *
   * @var \Drupal\block\BlockInterface
   */
  protected $block;

  /**
   * The group that is considered to be "currently active" in the test.
   *
   * This group will be returned by the mocked OgContext service.
   *
   * @var \Drupal\entity_test\Entity\EntityTest
   */
  protected $activeGroup;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this
      ->installEntitySchema('entity_test');
    $this
      ->installEntitySchema('user');
    $this
      ->installEntitySchema('og_membership');
    $this
      ->installConfig([
      'system',
      'block',
      'og',
    ]);
    $this
      ->installSchema('system', [
      'sequences',
    ]);
    $this->groupTypeManager = $this->container
      ->get('og.group_type_manager');
    $this->entityTypeManager = $this->container
      ->get('entity_type.manager');
    $this->blockStorage = $this->entityTypeManager
      ->getStorage('block');
    $this->blockViewBuilder = $this->entityTypeManager
      ->getViewBuilder('block');
    $this->cacheTagsInvalidator = $this->container
      ->get('cache_tags.invalidator');
    $this->renderer = $this->container
      ->get('renderer');
    $this->renderCache = $this->container
      ->get('render_cache');

    // The block being tested shows the member count of the currently active
    // group, which it gets from OgContext. Mock OgContext using a callback to
    // set the active group that will be used during the test.
    $og_context = $this
      ->prophesize(OgContextInterface::class);
    $og_context
      ->getGroup()
      ->will(new CallbackPromise([
      $this,
      'getActiveGroup',
    ]));
    $this->container
      ->set('og.context', $og_context
      ->reveal());

    // Create a group type.
    $this->groupTypeManager
      ->addGroup('entity_test', 'group');

    // Create two test groups.
    for ($i = 0; $i < 2; $i++) {
      $this->groups[$i] = EntityTest::create([
        'type' => 'group',
        'name' => $this
          ->randomString(),
      ]);
      $this->groups[$i]
        ->save();
    }

    // Create a test block.
    $this->block = $this->blockStorage
      ->create([
      'plugin' => 'og_member_count',
      'region' => 'sidebar_first',
      'id' => 'group_member_count',
      'theme' => $this
        ->config('system.theme')
        ->get('default'),
      'label' => 'Group member count',
      'visibility' => [],
      'weight' => 0,
    ]);
    $this->block
      ->save();
  }

  /**
   * Tests the member count block.
   */
  public function testMemberCountBlock() {

    // Before the blocks are rendered for the first time, no cache entries
    // should exist for them. We have two groups, so let's test both blocks.
    $this
      ->assertNotCached(0);
    $this
      ->assertNotCached(1);

    // After rendering the first block, only this block should be cached, the
    // other should be unaffected.
    $this
      ->renderBlock(0);
    $this
      ->assertCached(0);
    $this
      ->assertNotCached(1);
    $this
      ->renderBlock(1);
    $this
      ->assertCached(1);

    // Initially the blocks should have 0 members.
    $this
      ->assertMemberCount(0, 0);
    $this
      ->assertMemberCount(1, 0);

    // In the default configuration the block should only count active users,
    // and ignore blocked and pending users. Also check that making changes to
    // the members of the group only invalidates the cache of the related block.
    $this
      ->addMember(0, OgMembershipInterface::STATE_BLOCKED);
    $this
      ->addMember(0, OgMembershipInterface::STATE_PENDING);
    $this
      ->assertNotCached(0);
    $this
      ->assertCached(1);
    $this
      ->assertMemberCount(0, 0);

    // However adding an active user increases the member count.
    $active_membership = $this
      ->addMember(0, OgMembershipInterface::STATE_ACTIVE);
    $this
      ->assertMemberCount(0, 1);

    // If we block the active user, the member count should be updated
    // accordingly.
    $active_membership
      ->setState(OgMembershipInterface::STATE_BLOCKED)
      ->save();
    $this
      ->assertMemberCount(0, 0);

    // Check that both blocks are invalidated when the block settings are
    // changed.
    $this
      ->updateBlockSetting('count_pending_users', TRUE);
    $this
      ->assertNotCached(0);
    $this
      ->assertNotCached(1);

    // The block has now been configured to also count pending members. Check if
    // the count is updated accordingly.
    $this
      ->assertMemberCount(0, 1);
    $this
      ->assertMemberCount(1, 0);

    // Turn on the counting of blocked members and check the resulting value.
    $this
      ->updateBlockSetting('count_blocked_users', TRUE);
    $this
      ->assertMemberCount(0, 3);
    $this
      ->assertMemberCount(1, 0);

    // Now delete one of the memberships of the first group. This should
    // decrease the counter.
    $active_membership
      ->delete();
    $this
      ->assertMemberCount(0, 2);

    // Since the deletion of the user only affected the first group, the block
    // of the second group should still be unchanged and happily cached.
    $this
      ->assertCached(1);
    $this
      ->assertMemberCount(1, 0);

    // For good measure, try to add a user to the second group and check that
    // all is in order.
    $this
      ->addMember(1, OgMembershipInterface::STATE_ACTIVE);
    $this
      ->assertMemberCount(1, 1);

    // The block from the first group should not be affected by this.
    $this
      ->assertCached(0);
    $this
      ->assertMemberCount(0, 2);
  }

  /**
   * Renders the block using the passed in group as the currently active group.
   *
   * @param int $group_key
   *   The key of the group to set as active group.
   *
   * @return string
   *   The content of the block rendered as HTML.
   */
  protected function renderBlock($group_key) {

    // Clear the static caches of the cache tags invalidators. The invalidators
    // will only invalidate cache tags once per request to improve performance.
    // Unfortunately they can not distinguish between an actual Drupal page
    // request and a PHPUnit test that simulates visiting multiple pages.
    // We are pretending that every time this method is called a new page has
    // been requested, and the static caches are empty.
    $this->cacheTagsInvalidator
      ->resetChecksums();
    $this->activeGroup = $this->groups[$group_key];
    $render_array = $this->blockViewBuilder
      ->view($this->block);
    $html = $this->renderer
      ->renderRoot($render_array);

    // At all times, after a block is rendered, it should be cached.
    $this
      ->assertCached($group_key);
    return $html;
  }

  /**
   * Checks that the block shows the correct member count for the given group.
   *
   * @param int $group_key
   *   The key of the group for which to check the block.
   * @param int $expected_count
   *   The number of members that are expected to be shown in the block.
   */
  protected function assertMemberCount($group_key, $expected_count) {
    $expected_string = (string) $this
      ->formatPlural($expected_count, '@label has 1 member.', '@label has @count members', [
      '@label' => $this->groups[$group_key]
        ->label(),
    ]);

    // @todo Use assertStringContainsString() once we are on PHPUnit 9.
    $this
      ->assertTrue(strpos((string) $this
      ->renderBlock($group_key), $expected_string) !== FALSE);
  }

  /**
   * Adds a member with the given membership state to the given group.
   *
   * @param int $group_key
   *   The key of the group to which a member should be added.
   * @param string $state
   *   The membership state to assign to the newly added member.
   *
   * @return \Drupal\og\OgMembershipInterface
   *   The membership entity for the newly added member.
   */
  protected function addMember($group_key, $state) {
    $user = $this
      ->createUser();
    return $this
      ->createOgMembership($this->groups[$group_key], $user, NULL, $state);
  }

  /**
   * Updates the given setting in the block with the given value.
   *
   * @param string $setting
   *   The setting to update.
   * @param mixed $value
   *   The value to set.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   *   Thrown when the updated block cannot be saved.
   */
  protected function updateBlockSetting($setting, $value) {
    $settings = $this->block
      ->get('settings');
    $settings[$setting] = $value;
    $this->block
      ->set('settings', $settings)
      ->save();
  }

  /**
   * Checks that the block is cached for the given group.
   *
   * @param int $group_key
   *   The key of the group for which to check the block cache status.
   */
  protected function assertCached($group_key) {
    $this
      ->doAssertCached('assertNotEmpty', $group_key);
  }

  /**
   * Checks that the block is not cached for the given group.
   *
   * @param int $group_key
   *   The key of the group for which to check the block cache status.
   */
  protected function assertNotCached($group_key) {
    $this
      ->doAssertCached('assertEmpty', $group_key);
  }

  /**
   * Checks the cache status of the block for the given group.
   *
   * @param string $assert_method
   *   The method to use for asserting that the block is cached or not cached.
   * @param int $group_key
   *   The key of the group for which to check the block cache status.
   */
  protected function doAssertCached($assert_method, $group_key) {

    // We will switch the currently active context so that the right cache
    // contexts are available for the render cache. Keep track of the currently
    // active group so we can restore it after checking the cache status.
    $original_active_group = $this->activeGroup;
    $this->activeGroup = $this->groups[$group_key];

    // Retrieve the block to render, and apply the required cache contexts that
    // are also applied when RendererInterface::renderRoot() is executed. This
    // ensures that we pass the same cache information to the render cache as is
    // done when actually rendering the HTML root.
    $render_array = $this->blockViewBuilder
      ->view($this->block);
    $render_array['#cache']['contexts'] = Cache::mergeContexts($render_array['#cache']['contexts'], $this->container
      ->getParameter('renderer.config')['required_cache_contexts']);

    // Retrieve the cached data and perform the assertion.
    $cached_data = $this->renderCache
      ->get($render_array);
    $this
      ->{$assert_method}($cached_data);

    // Restore the active group.
    $this->activeGroup = $original_active_group;
  }

  /**
   * Callback providing the active group to be returned by the mocked OgContext.
   *
   * @return \Drupal\entity_test\Entity\EntityTest
   *   The active group.
   */
  public function getActiveGroup() {
    return $this->activeGroup;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::getUrl protected function Get the current URL from the cURL handler. 1
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.
AssertLegacyTrait::assert protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::assertEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead.
AssertLegacyTrait::assertIdenticalObject protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertNotEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead.
AssertLegacyTrait::assertNotIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead.
AssertLegacyTrait::pass protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::verbose protected function
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
KernelTestBase::$backupGlobals protected property Back up and restore any global variables that may be changed by tests.
KernelTestBase::$backupStaticAttributes protected property Back up and restore static class properties that may be changed by tests.
KernelTestBase::$backupStaticAttributesBlacklist protected property Contains a few static class properties for performance.
KernelTestBase::$classLoader protected property
KernelTestBase::$configImporter protected property @todo Move into Config test base class. 7
KernelTestBase::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
KernelTestBase::$container protected property
KernelTestBase::$databasePrefix protected property
KernelTestBase::$preserveGlobalState protected property Do not forward any global state from the parent process to the processes that run the actual tests.
KernelTestBase::$root protected property The app root.
KernelTestBase::$runTestInSeparateProcess protected property Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property.
KernelTestBase::$siteDirectory protected property
KernelTestBase::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 6
KernelTestBase::$vfsRoot protected property The virtual filesystem root directory.
KernelTestBase::assertPostConditions protected function 1
KernelTestBase::bootEnvironment protected function Bootstraps a basic test environment.
KernelTestBase::bootKernel private function Bootstraps a kernel for a test.
KernelTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
KernelTestBase::disableModules protected function Disables modules for this test.
KernelTestBase::enableModules protected function Enables modules for this test.
KernelTestBase::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
KernelTestBase::getDatabaseConnectionInfo protected function Returns the Database connection info to be used for this test. 1
KernelTestBase::getDatabasePrefix public function
KernelTestBase::getExtensionsForModules private function Returns Extension objects for $modules to enable.
KernelTestBase::getModulesToEnable private static function Returns the modules to enable for this test.
KernelTestBase::initFileCache protected function Initializes the FileCache component.
KernelTestBase::installConfig protected function Installs default configuration for a given list of modules.
KernelTestBase::installEntitySchema protected function Installs the storage schema for a specific entity type.
KernelTestBase::installSchema protected function Installs database tables from a module schema definition.
KernelTestBase::isTestInIsolation Deprecated protected function Returns whether the current test method is running in a separate process.
KernelTestBase::prepareTemplate protected function
KernelTestBase::register public function Registers test-specific services. Overrides ServiceProviderInterface::register 26
KernelTestBase::render protected function Renders a render array. 1
KernelTestBase::setInstallProfile protected function Sets the install profile and rebuilds the container to update it.
KernelTestBase::setSetting protected function Sets an in-memory Settings variable.
KernelTestBase::setUpBeforeClass public static function 1
KernelTestBase::setUpFilesystem protected function Sets up the filesystem, so things like the file directory. 2
KernelTestBase::stop protected function Stops test execution.
KernelTestBase::tearDown protected function 6
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__get Deprecated public function BC: Automatically resolve former KernelTestBase class properties.
KernelTestBase::__sleep public function Prevents serializing any properties.
MemberCountBlockTest::$activeGroup protected property The group that is considered to be "currently active" in the test.
MemberCountBlockTest::$block protected property A test block. This is the system under test.
MemberCountBlockTest::$blockStorage protected property The block storage handler.
MemberCountBlockTest::$blockViewBuilder protected property The block view builder.
MemberCountBlockTest::$cacheTagsInvalidator protected property The cache tags invalidator.
MemberCountBlockTest::$entityTypeManager protected property The entity type manager.
MemberCountBlockTest::$groups protected property Test groups.
MemberCountBlockTest::$groupTypeManager protected property The group type manager.
MemberCountBlockTest::$modules protected static property Modules to enable. Overrides KernelTestBase::$modules
MemberCountBlockTest::$renderCache protected property The render cache.
MemberCountBlockTest::$renderer protected property The renderer.
MemberCountBlockTest::addMember protected function Adds a member with the given membership state to the given group.
MemberCountBlockTest::assertCached protected function Checks that the block is cached for the given group.
MemberCountBlockTest::assertMemberCount protected function Checks that the block shows the correct member count for the given group.
MemberCountBlockTest::assertNotCached protected function Checks that the block is not cached for the given group.
MemberCountBlockTest::doAssertCached protected function Checks the cache status of the block for the given group.
MemberCountBlockTest::getActiveGroup public function Callback providing the active group to be returned by the mocked OgContext.
MemberCountBlockTest::renderBlock protected function Renders the block using the passed in group as the currently active group.
MemberCountBlockTest::setUp protected function Overrides KernelTestBase::setUp
MemberCountBlockTest::testMemberCountBlock public function Tests the member count block.
MemberCountBlockTest::updateBlockSetting protected function Updates the given setting in the block with the given value.
OgMembershipCreationTrait::createOgMembership protected function Creates a test membership.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers. 1
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TestRequirementsTrait::checkModuleRequirements private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements protected function Check module requirements for the Drupal use case. 1
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
UserCreationTrait::checkPermissions protected function Checks whether a given list of permission names is valid.
UserCreationTrait::createAdminRole protected function Creates an administrative role.
UserCreationTrait::createRole protected function Creates a role with specified permissions.
UserCreationTrait::createUser protected function Create a user with a given set of permissions.
UserCreationTrait::grantPermissions protected function Grant permissions to a user role.
UserCreationTrait::setCurrentUser protected function Switch the current logged in user.
UserCreationTrait::setUpCurrentUser protected function Creates a random user account and sets it as current user.