You are here

public function OgLocalTaskTest::testGetDerivativeDefinitions in Organic groups 8

Tests setting local task definitions.

@covers ::getDerivativeDefinitions

File

tests/src/Unit/OgLocalTaskTest.php, line 63

Class

OgLocalTaskTest
Tests OG local task definition.

Namespace

Drupal\Tests\og\Unit

Code

public function testGetDerivativeDefinitions() {
  $entity_type_id1 = $this
    ->randomMachineName();
  $entity_type_id2 = $this
    ->randomMachineName();
  $group_map = [
    // We don't need to add the bundles data, as they are skipped by doing
    // array_keys() on the tested method.
    $entity_type_id1 => [],
    $entity_type_id2 => [],
  ];
  $this->groupTypeManager
    ->getGroupMap()
    ->willReturn($group_map);
  foreach (array_keys($group_map) as $entity_type_id) {
    $route_name = "entity.{$entity_type_id}.og_admin_routes";
    $this->routeProvider
      ->getRoutesByNames([
      $route_name,
    ])
      ->willReturn([
      $this->route
        ->reveal(),
      $this->route
        ->reveal(),
    ]);
  }
  $og_local_task = new OgLocalTask($this->groupTypeManager
    ->reveal(), $this->routeProvider
    ->reveal());
  $derivatives = $og_local_task
    ->getDerivativeDefinitions([]);
  $this
    ->assertCount(2, $derivatives);
}