EntityListBuilder example

$url->expects($this->atLeastOnce())
      ->method('mergeOptions')
      ->with(['query' => ['destination' => '/foo/bar']]);
    $this->role->expects($this->any())
      ->method('toUrl')
      ->willReturn($url);

    $this->redirectDestination->expects($this->atLeastOnce())
      ->method('getAsArray')
      ->willReturn(['destination' => '/foo/bar']);

    $list = new EntityListBuilder($this->entityType, $this->roleStorage);
    $list->setStringTranslation($this->translationManager);
    $list->setRedirectDestination($this->redirectDestination);

    $operations = $list->getOperations($this->role);
    $this->assertIsArray($operations);
    $this->assertArrayHasKey('edit', $operations);
    $this->assertIsArray($operations['edit']);
    $this->assertArrayHasKey('title', $operations['edit']);
    $this->assertArrayHasKey('delete', $operations);
    $this->assertIsArray($operations['delete']);
    $this->assertArrayHasKey('title', $operations['delete']);
    
Home | Imprint | This part of the site doesn't use cookies.