function EntityOperationsTest::testEntityOperationAlter

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest::testEntityOperationAlter()
  2. 8.9.x core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest::testEntityOperationAlter()
  3. 10 core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest::testEntityOperationAlter()

Checks that hook_entity_operation_alter() can add an operation.

See also

entity_test_entity_operation_alter()

File

core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php, line 42

Class

EntityOperationsTest
Tests that operations can be injected from the hook.

Namespace

Drupal\Tests\system\Functional\Entity

Code

public function testEntityOperationAlter() : void {
    // Check that role listing contain our test_operation operation.
    $this->drupalGet('admin/people/roles');
    $roles = Role::loadMultiple();
    foreach ($roles as $role) {
        $this->assertSession()
            ->linkByHrefExists($role->toUrl()
            ->toString() . '/test_operation');
        $this->assertSession()
            ->linkExists('Test Operation: ' . $role->label());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.