You are here

protected function OgResolvedGroupCollectionTest::setUp in Organic groups 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/OgResolvedGroupCollectionTest.php, line 29

Class

OgResolvedGroupCollectionTest
Tests the collecting of resolved groups to pass as a route context.

Namespace

Drupal\Tests\og\Unit

Code

protected function setUp() : void {
  parent::setUp();

  // Mock some test groups.
  $entity_types = [
    'node',
    'entity_test',
    'taxonomy_term',
    'block_content',
  ];
  foreach ($entity_types as $entity_type) {
    for ($i = 0; $i < 2; $i++) {
      $entity_id = "{$entity_type}-{$i}";

      /** @var \Drupal\Core\Entity\ContentEntityInterface|\Prophecy\Prophecy\ObjectProphecy $entity */
      $entity = $this
        ->prophesize(ContentEntityInterface::class);
      $entity
        ->getEntityTypeId()
        ->willReturn($entity_type);
      $entity
        ->id()
        ->willReturn($entity_id);
      $this->groups[$entity_id] = $entity
        ->reveal();
    }
  }
}