public function GroupMembershipManagerTest::testGetGroupIdsInvalidArguments in Organic groups 8
Tests that exceptions are thrown when invalid arguments are passed.
@covers ::getGroupIds @dataProvider groupContentProvider
File
- tests/
src/ Kernel/ Entity/ GroupMembershipManagerTest.php, line 203
Class
- GroupMembershipManagerTest
- Tests retrieving groups associated with a given group content.
Namespace
Drupal\Tests\og\Kernel\EntityCode
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.
}
}
}