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. 10 core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest::testEntityOperationAlter()
  3. 11.x 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 39

Class

EntityOperationsTest
Tests that operations can be injected from the hook.

Namespace

Drupal\Tests\system\Functional\Entity

Code

public function testEntityOperationAlter() {
    // Check that role listing contain our test_operation operation.
    $this->drupalGet('admin/people/roles');
    $roles = user_roles();
    foreach ($roles as $role) {
        $this->assertLinkByHref($role->toUrl()
            ->toString() . '/test_operation');
        $this->assertSession()
            ->linkExists(new FormattableMarkup('Test Operation: @label', [
            '@label' => $role->label(),
        ]));
    }
}

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