class GroupMembershipManagerTest in Organic groups 8
Tests retrieving groups associated with a given group content.
@group og @coversDefaultClass \Drupal\og\MembershipManager
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses AssertContentTrait, AssertLegacyTrait, AssertHelperTrait, ConfigTestTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait
- class \Drupal\Tests\og\Kernel\Entity\GroupMembershipManagerTest uses OgMembershipCreationTrait
Expanded class hierarchy of GroupMembershipManagerTest
File
- tests/
src/ Kernel/ Entity/ GroupMembershipManagerTest.php, line 28
Namespace
Drupal\Tests\og\Kernel\EntityView source
class GroupMembershipManagerTest extends KernelTestBase {
use OgMembershipCreationTrait;
/**
* {@inheritdoc}
*/
public static $modules = [
'entity_test',
'field',
'node',
'og',
'system',
'user',
];
/**
* Test groups.
*
* @var \Drupal\Core\Entity\EntityInterface[][]
*/
protected $groups;
/**
* Test group content.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $groupContent;
/**
* Test users.
*
* @var \Drupal\user\UserInterface[]
*/
protected $users;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The membership manager. This is the system under test.
*
* @var \Drupal\og\MembershipManagerInterface
*/
protected $membershipManager;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'og',
]);
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('entity_test_rev');
$this
->installEntitySchema('entity_test_with_bundle');
$this
->installEntitySchema('node');
$this
->installEntitySchema('og_membership');
$this
->installEntitySchema('user');
$this
->installSchema('system', 'sequences');
$this
->installSchema('user', 'users_data');
$this->entityTypeManager = $this->container
->get('entity_type.manager');
$this->membershipManager = $this->container
->get('og.membership_manager');
$this->groups = [];
// Create group admin user.
$group_admin = User::create([
'name' => $this
->randomString(),
]);
$group_admin
->save();
$this->users[0] = $group_admin;
// Create four groups of two different entity types.
for ($i = 0; $i < 2; $i++) {
$bundle = "node_{$i}";
NodeType::create([
'name' => $this
->randomString(),
'type' => $bundle,
])
->save();
Og::groupTypeManager()
->addGroup('node', $bundle);
$group = Node::create([
'title' => $this
->randomString(),
'type' => $bundle,
'uid' => $group_admin
->id(),
]);
$group
->save();
$this->groups['node'][] = $group;
// The Entity Test entity doesn't have 'real' bundles, so we don't need to
// create one, we can just add the group to the fake bundle.
$bundle = "entity_test_{$i}";
Og::groupTypeManager()
->addGroup('entity_test', $bundle);
$group = EntityTest::create([
'type' => $bundle,
'name' => $this
->randomString(),
'uid' => $group_admin
->id(),
]);
$group
->save();
$this->groups['entity_test'][] = $group;
}
// Create a group content type with two group audience fields, one for each
// group.
$bundle = mb_strtolower($this
->randomMachineName());
foreach ([
'entity_test',
'node',
] as $target_type) {
$settings = [
'field_name' => 'group_audience_' . $target_type,
'field_storage_config' => [
'settings' => [
'target_type' => $target_type,
],
],
];
Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test', $bundle, $settings);
}
// Create a group content entity that references all four groups.
$values = [
'name' => $this
->randomString(),
'type' => $bundle,
];
foreach ([
'entity_test',
'node',
] as $target_type) {
foreach ($this->groups[$target_type] as $group) {
$values['group_audience_' . $target_type][] = [
'target_id' => $group
->id(),
];
}
}
$this->groupContent = $this->entityTypeManager
->getStorage('entity_test')
->create($values);
$this->groupContent
->save();
}
/**
* Tests retrieval of groups IDs that are associated with given group content.
*
* @param string $group_type_id
* Optional group type ID to be passed as an argument to the method under
* test.
* @param string $group_bundle
* Optional group bundle to be passed as an argument to the method under
* test.
* @param array $expected
* An array containing the expected results to be returned.
*
* @covers ::getGroupIds
* @dataProvider groupContentProvider
*/
public function testGetGroupIds($group_type_id, $group_bundle, array $expected) {
$result = $this->membershipManager
->getGroupIds($this->groupContent, $group_type_id, $group_bundle);
// Check that the correct number of results is returned.
$this
->assertEquals(count($expected, COUNT_RECURSIVE), count($result, COUNT_RECURSIVE));
// Check that all expected results are returned.
foreach ($expected as $expected_type => $expected_keys) {
foreach ($expected_keys as $expected_key) {
$this
->assertTrue(in_array($this->groups[$expected_type][$expected_key]
->id(), $result[$expected_type]));
}
}
}
/**
* Tests that exceptions are thrown when invalid arguments are passed.
*
* @covers ::getGroupIds
* @dataProvider groupContentProvider
*/
public function testGetGroupIdsInvalidArguments() {
/** @var \Drupal\og\MembershipManagerInterface $membership_manager */
$membership_manager = \Drupal::service('og.membership_manager');
$test_cases = [
// Test that an exception is thrown when passing a User entity.
User::create(),
// Test that an exception is thrown when passing an entity which is not
// group content. We are using one of the test groups for this.
$this->groups['node'][0],
];
foreach ($test_cases as $test_case) {
try {
$membership_manager
->getGroupIds($test_case);
$this
->fail();
} catch (\InvalidArgumentException $e) {
// Expected result.
}
}
}
/**
* Tests that the static cache loads the appropriate group.
*
* Verify that entities from different entity types with colliding Ids that
* point to different groups do not confuse the membership manager.
*
* @covers ::getGroups
*/
public function testStaticCache() {
$bundle_rev = mb_strtolower($this
->randomMachineName());
$bundle_with_bundle = mb_strtolower($this
->randomMachineName());
EntityTestBundle::create([
'id' => $bundle_with_bundle,
'label' => $bundle_with_bundle,
])
->save();
$field_settings = [
'field_name' => 'group_audience_node',
'field_storage_config' => [
'settings' => [
'target_type' => 'node',
],
],
];
Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test_rev', $bundle_rev, $field_settings);
Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test_with_bundle', $bundle_with_bundle, $field_settings);
$group_content_rev = EntityTestRev::create([
'type' => $bundle_rev,
'name' => $this
->randomString(),
'group_audience_node' => [
0 => [
'target_id' => $this->groups['node'][0]
->id(),
],
],
]);
$group_content_rev
->save();
$group_content_with_bundle = EntityTestWithBundle::create([
'type' => $bundle_with_bundle,
'name' => $this
->randomString(),
'group_audience_node' => [
0 => [
'target_id' => $this->groups['node'][1]
->id(),
],
],
]);
$group_content_with_bundle
->save();
// Ensure that both entities share the same Id. This is an assertion to
// ensure that the next assertions are addressing the proper issue.
$this
->assertEquals($group_content_rev
->id(), $group_content_with_bundle
->id());
$group_content_rev_group = $this->membershipManager
->getGroups($group_content_rev);
/** @var \Drupal\node\NodeInterface $group */
$group = reset($group_content_rev_group['node']);
$this
->assertEquals($this->groups['node'][0]
->id(), $group
->id());
$group_content_with_bundle_group = $this->membershipManager
->getGroups($group_content_with_bundle);
$group = reset($group_content_with_bundle_group['node']);
$this
->assertEquals($this->groups['node'][1]
->id(), $group
->id());
}
/**
* Tests retrieval of groups that are associated with a given group content.
*
* @param string $group_type_id
* Optional group type ID to be passed as an argument to the method under
* test.
* @param string $group_bundle
* Optional group bundle to be passed as an argument to the method under
* test.
* @param array $expected
* An array containing the expected results to be returned.
*
* @covers ::getGroups
* @dataProvider groupContentProvider
*/
public function testGetGroups($group_type_id, $group_bundle, array $expected) {
$result = $this->membershipManager
->getGroups($this->groupContent, $group_type_id, $group_bundle);
// Check that the correct number of results is returned.
$this
->assertEquals(count($expected, COUNT_RECURSIVE), count($result, COUNT_RECURSIVE));
// Check that all expected results are returned.
foreach ($expected as $expected_type => $expected_keys) {
foreach ($expected_keys as $expected_key) {
/** @var \Drupal\Core\Entity\EntityInterface $expected_group */
$expected_group = $this->groups[$expected_type][$expected_key];
/** @var \Drupal\Core\Entity\EntityInterface $group */
foreach ($result[$expected_type] as $group) {
if ($group
->getEntityTypeId() === $expected_group
->getEntityTypeId() && $group
->id() === $expected_group
->id()) {
// The expected result was found. Continue the test.
continue 2;
}
}
// The expected result was not found.
$this
->fail("The expected group of type {$expected_type} and key {$expected_key} is found.");
}
}
}
/**
* Tests if the number of groups associated with group content is correct.
*
* @param string $group_type_id
* Optional group type ID to be passed as an argument to the method under
* test.
* @param string $group_bundle
* Optional group bundle to be passed as an argument to the method under
* test.
* @param array $expected
* An array containing the expected results to be returned.
*
* @covers ::getGroupCount
* @dataProvider groupContentProvider
*/
public function testGetGroupCount($group_type_id, $group_bundle, array $expected) {
$result = $this->membershipManager
->getGroupCount($this->groupContent, $group_type_id, $group_bundle);
// Check that the correct results is returned.
$this
->assertEquals(count($expected, COUNT_RECURSIVE) - count($expected), $result);
}
/**
* Provides test data.
*
* @return array
* An array of test properties. Each property is an indexed array with the
* following items:
* - An optional string indicating the group type ID to be returned.
* - An optional string indicating the group bundle to be returned.
* - An array containing the expected results to be returned.
*/
public function groupContentProvider() {
return [
[
NULL,
NULL,
[
'node' => [
0,
1,
],
'entity_test' => [
0,
1,
],
],
],
[
'node',
NULL,
[
'node' => [
0,
1,
],
],
],
[
'entity_test',
NULL,
[
'entity_test' => [
0,
1,
],
],
],
[
'node',
'node_0',
[
'node' => [
0,
],
],
],
[
'entity_test',
'entity_test_1',
[
'entity_test' => [
1,
],
],
],
];
}
/**
* Tests retrieval of group memberships filtered by role names.
*
* @covers ::getGroupMembershipsByRoleNames
*/
public function testGetGroupMembershipsByRoleNames() {
$retrieve_membership_owner_id = function (OgMembershipInterface $membership) {
return $membership
->getOwnerId();
};
$this
->doTestGetGroupMembershipsByRoleNames('getGroupMembershipsByRoleNames', $retrieve_membership_owner_id);
}
/**
* Tests retrieval of group membership IDs filtered by role names.
*
* @covers ::getGroupMembershipIdsByRoleNames
*/
public function testGetGroupMembershipIdsByRoleNames() {
$membership_storage = $this->container
->get('entity_type.manager')
->getStorage('og_membership');
$retrieve_membership_owner_id = function ($membership_id) use ($membership_storage) {
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $membership_storage
->load($membership_id);
return $membership
->getOwnerId();
};
$this
->doTestGetGroupMembershipsByRoleNames('getGroupMembershipIdsByRoleNames', $retrieve_membership_owner_id);
}
/**
* Tests retrieval of group memberships or their IDs filtered by role names.
*
* Contains the actual test logic of ::testGetGroupMembershipsByRoleNames()
* and ::testGetGroupMembershipIdsByRoleNames().
*
* @param string $method_name
* The name of the method under test. Can be one of the following:
* - 'getGroupMembershipIdsByRoleNames'
* - 'getGroupMembershipsByRoleNames'.
* @param callable $retrieve_membership_owner_id
* A callable that will retrieve the ID of the owner of the membership or
* membership ID.
*/
protected function doTestGetGroupMembershipsByRoleNames($method_name, callable $retrieve_membership_owner_id) {
$this
->createTestMemberships();
// Check that an exception is thrown if no role names are passed.
try {
$this->membershipManager
->{$method_name}($this->groups['node'][0], []);
$this
->fail('MembershipManager::getGroupsMembershipsByRoleNames() throws an exception when called without passing any role names.');
} catch (\InvalidArgumentException $e) {
// Expected result.
}
// Define a test matrix to iterate over. We're not using a data provider
// because the large number of test cases would slow down the test too much.
// The test matrix has the following structure:
// @code
// [
// // The machine name of the group entity type being tested.
// {entity_type_id} => [
// // The key of the test group as created in ::setUp().
// {group_key} => [ //
// // The roles being passed to the method.
// 'roles' => [{role_id}],
// // The membership states being passed to the method.
// 'states' => [{state_id}],
// // The memberships that should be returned by the method.
// 'expected_memberships' => [{expected_membership_id}],
// ],
// ],
// ];
// @endcode
$matrix = [
'node' => [
0 => [
// All memberships with all possible states. The authenticated role
// covers all memberships.
[
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
'states' => OgMembershipInterface::ALL_STATES,
'expected_memberships' => [
0,
1,
4,
7,
],
],
// All memberships with all possible states, by passing an empty
// states array, and passing all defined roles.
[
'roles' => [
OgRoleInterface::AUTHENTICATED,
OgRoleInterface::ADMINISTRATOR,
'moderator',
],
'states' => [],
'expected_memberships' => [
0,
1,
4,
7,
],
],
// Pending members.
[
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
'states' => [
OgMembershipInterface::STATE_PENDING,
],
'expected_memberships' => [
4,
],
],
],
1 => [
// All administrators.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
'states' => [],
'expected_memberships' => [
2,
6,
],
],
// Pending administrators.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
'states' => [
OgMembershipInterface::STATE_PENDING,
],
'expected_memberships' => [
2,
],
],
// Blocked administrators. There are none.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
'states' => [
OgMembershipInterface::STATE_BLOCKED,
],
'expected_memberships' => [],
],
// Pending and blocked administrators and moderators. Should be the
// same result as the pending administrators, since there are no
// moderators or blocked users.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
'moderator',
],
'states' => [
OgMembershipInterface::STATE_BLOCKED,
OgMembershipInterface::STATE_PENDING,
],
'expected_memberships' => [
2,
],
],
// Switch the order of the arguments, this should not affect the
// result.
[
'roles' => [
'moderator',
OgRoleInterface::ADMINISTRATOR,
],
'states' => [
OgMembershipInterface::STATE_PENDING,
OgMembershipInterface::STATE_BLOCKED,
],
'expected_memberships' => [
2,
],
],
// There are no pending or blocked moderators.
[
'roles' => [
'moderator',
],
'states' => [
OgMembershipInterface::STATE_BLOCKED,
OgMembershipInterface::STATE_PENDING,
],
'expected_memberships' => [],
],
],
],
'entity_test' => [
0 => [
// The first test entity group doesn't have any moderators or admins.
// Check that duplicated array values doesn't affect the result.
[
'roles' => [
'moderator',
OgRoleInterface::ADMINISTRATOR,
'moderator',
'moderator',
OgRoleInterface::ADMINISTRATOR,
],
'states' => [
OgMembershipInterface::STATE_ACTIVE,
OgMembershipInterface::STATE_BLOCKED,
OgMembershipInterface::STATE_PENDING,
OgMembershipInterface::STATE_PENDING,
OgMembershipInterface::STATE_BLOCKED,
OgMembershipInterface::STATE_ACTIVE,
],
'expected_memberships' => [],
],
],
// Check active members.
[
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
'states' => [
OgMembershipInterface::STATE_ACTIVE,
],
'expected_memberships' => [
0,
3,
],
],
1 => [
// There are two blocked users in the second test entity group.
[
'roles' => [
OgRoleInterface::AUTHENTICATED,
OgRoleInterface::ADMINISTRATOR,
'moderator',
],
'states' => [
OgMembershipInterface::STATE_BLOCKED,
],
'expected_memberships' => [
4,
7,
],
],
// There is one pending administrator, just as in the node group with
// the same entity ID. This ensures that the correct result will be
// returned for groups that have different entity types but the same
// entity ID.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
'states' => [
OgMembershipInterface::STATE_PENDING,
],
'expected_memberships' => [
8,
],
],
// There is one blocked moderator.
[
'roles' => [
OgRoleInterface::ADMINISTRATOR,
'moderator',
],
'states' => [
OgMembershipInterface::STATE_BLOCKED,
],
'expected_memberships' => [
4,
],
],
],
],
];
foreach ($matrix as $entity_type_id => $groups) {
foreach ($groups as $group_key => $test_cases) {
foreach ($test_cases as $test_case) {
$group = $this->groups[$entity_type_id][$group_key];
$role_names = $test_case['roles'];
$states = $test_case['states'];
$expected_memberships = $test_case['expected_memberships'];
$actual_memberships = $this->membershipManager
->{$method_name}($group, $role_names, $states);
$this
->assertSameSize($expected_memberships, $actual_memberships);
foreach ($expected_memberships as $expected_membership_key) {
$expected_user_id = $this->users[$expected_membership_key]
->id();
foreach ($actual_memberships as $actual_membership) {
if ($retrieve_membership_owner_id($actual_membership) == $expected_user_id) {
// Match found.
continue 2;
}
}
// The expected membership was not returned. Fail the test.
$this
->fail("The membership for user {$expected_membership_key} is present in the result.");
}
}
}
}
// Test that the correct memberships are returned when one of the users is
// deleted. We are using the second node group as a test case. This group
// has one pending administrator: the user with key '2'.
$group = $this->groups['node'][1];
$role_names = [
OgRoleInterface::ADMINISTRATOR,
];
$states = [
OgMembershipInterface::STATE_PENDING,
];
$memberships = $this->membershipManager
->{$method_name}($group, $role_names, $states);
$this
->assertCount(1, $memberships);
// Delete the user and check that it no longer appears in the result.
$this->users[2]
->delete();
$memberships = $this->membershipManager
->{$method_name}($group, $role_names, $states);
$this
->assertCount(0, $memberships);
}
/**
* Creates a number of users that are members of the test groups.
*/
protected function createTestMemberships() {
// Create a 'moderator' role in each of the test group types.
foreach ([
'node',
'entity_test',
] as $entity_type_id) {
for ($i = 0; $i < 2; $i++) {
$bundle = "{$entity_type_id}_{$i}";
$og_role = OgRole::create();
$og_role
->setName('moderator')
->setGroupType($entity_type_id)
->setGroupBundle($bundle)
->save();
}
}
// Create test users with different membership states in the various groups.
// Note that the group admin (test user 0) is also a member of all groups.
$matrix = [
// A user which is an active member of the first node group.
1 => [
'node' => [
0 => [
'state' => OgMembershipInterface::STATE_ACTIVE,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
],
],
// A user which is a pending administrator of the second node group.
2 => [
'node' => [
1 => [
'state' => OgMembershipInterface::STATE_PENDING,
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
],
],
],
// A user which is an active member of both test entity groups.
3 => [
'entity_test' => [
0 => [
'state' => OgMembershipInterface::STATE_ACTIVE,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
1 => [
'state' => OgMembershipInterface::STATE_ACTIVE,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
],
],
// A user which is a pending member of the first node group and a blocked
// moderator in the second test entity group.
4 => [
'node' => [
0 => [
'state' => OgMembershipInterface::STATE_PENDING,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
],
'entity_test' => [
1 => [
'state' => OgMembershipInterface::STATE_BLOCKED,
'roles' => [
'moderator',
],
],
],
],
// A user which is not subscribed to any of the groups.
5 => [],
// A user which is both an administrator and a moderator in the second
// node group.
6 => [
'node' => [
1 => [
'state' => OgMembershipInterface::STATE_ACTIVE,
'roles' => [
OgRoleInterface::ADMINISTRATOR,
'moderator',
],
],
],
],
// A troll who is banned everywhere.
7 => [
'node' => [
0 => [
'state' => OgMembershipInterface::STATE_BLOCKED,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
1 => [
'state' => OgMembershipInterface::STATE_BLOCKED,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
],
'entity_test' => [
0 => [
'state' => OgMembershipInterface::STATE_BLOCKED,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
1 => [
'state' => OgMembershipInterface::STATE_BLOCKED,
'roles' => [
OgRoleInterface::AUTHENTICATED,
],
],
],
],
// A user which is a pending administrator of the second test entity
// group.
8 => [
'entity_test' => [
1 => [
'state' => OgMembershipInterface::STATE_PENDING,
'roles' => [
OgRoleInterface::ADMINISTRATOR,
],
],
],
],
];
foreach ($matrix as $user_key => $entity_types) {
$user = User::create([
'name' => $this
->randomString(),
]);
$user
->save();
$this->users[$user_key] = $user;
foreach ($entity_types as $entity_type_id => $groups) {
foreach ($groups as $group_key => $membership_info) {
$group = $this->groups[$entity_type_id][$group_key];
$this
->createOgMembership($group, $user, $membership_info['roles'], $membership_info['state']);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
GroupMembershipManagerTest:: |
protected | property | The entity type manager. | |
GroupMembershipManagerTest:: |
protected | property | Test group content. | |
GroupMembershipManagerTest:: |
protected | property | Test groups. | |
GroupMembershipManagerTest:: |
protected | property | The membership manager. This is the system under test. | |
GroupMembershipManagerTest:: |
public static | property |
Modules to enable. Overrides KernelTestBase:: |
|
GroupMembershipManagerTest:: |
protected | property | Test users. | |
GroupMembershipManagerTest:: |
protected | function | Creates a number of users that are members of the test groups. | |
GroupMembershipManagerTest:: |
protected | function | Tests retrieval of group memberships or their IDs filtered by role names. | |
GroupMembershipManagerTest:: |
public | function | Provides test data. | |
GroupMembershipManagerTest:: |
protected | function |
Overrides KernelTestBase:: |
|
GroupMembershipManagerTest:: |
public | function | Tests if the number of groups associated with group content is correct. | |
GroupMembershipManagerTest:: |
public | function | Tests retrieval of groups IDs that are associated with given group content. | |
GroupMembershipManagerTest:: |
public | function | Tests that exceptions are thrown when invalid arguments are passed. | |
GroupMembershipManagerTest:: |
public | function | Tests retrieval of group membership IDs filtered by role names. | |
GroupMembershipManagerTest:: |
public | function | Tests retrieval of group memberships filtered by role names. | |
GroupMembershipManagerTest:: |
public | function | Tests retrieval of groups that are associated with a given group content. | |
GroupMembershipManagerTest:: |
public | function | Tests that the static cache loads the appropriate group. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
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:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 1 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | Returns whether the current test method is running in a separate process. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
26 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 6 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | BC: Automatically resolve former KernelTestBase class properties. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
OgMembershipCreationTrait:: |
protected | function | Creates a test membership. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. |