You are here

public function GroupTypeTest::testGroupType in Organic groups 8

Test creation and deletion of a group type.

File

tests/src/Kernel/Entity/GroupTypeTest.php, line 42

Class

GroupTypeTest
Test creation and deletion of group types.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function testGroupType() {

  // Create a content type.

  /** @var \Drupal\node\NodeTypeInterface $group_type */
  $group_type = NodeType::create([
    'type' => 'group',
    'name' => 'Group',
  ]);
  $group_type
    ->save();

  // Initially it should not be a group.
  $this
    ->assertFalse($this->groupTypeManager
    ->isGroup('node', 'group'));

  // Turn it into a group.
  $this->groupTypeManager
    ->addGroup('node', 'group');
  $this
    ->assertTrue($this->groupTypeManager
    ->isGroup('node', 'group'));

  // Delete the content type. It should no longer be a group.
  $group_type
    ->delete();
  $this
    ->assertFalse($this->groupTypeManager
    ->isGroup('node', 'group'));
}