class EntityOperationsTest
Same name in this branch
- 9 core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
Same name and namespace in other branches
- 11.x core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
- 11.x core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest
- 10 core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
- 10 core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest
- 8.9.x core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
- 8.9.x core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest
Tests that operations can be injected from the hook.
@group Entity
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Entity\EntityOperationsTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of EntityOperationsTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityOperationsTest.php, line 13
Namespace
Drupal\Tests\system\Functional\EntityView source
class EntityOperationsTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create and log in user.
$this->drupalLogin($this->drupalCreateUser([
'administer permissions',
]));
}
/**
* Checks that hook_entity_operation_alter() can add an operation.
*
* @see entity_test_entity_operation_alter()
*/
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->assertSession()
->linkByHrefExists($role->toUrl()
->toString() . '/test_operation');
$this->assertSession()
->linkExists(new FormattableMarkup('Test Operation: @label', [
'@label' => $role->label(),
]));
}
}
/**
* {@inheritdoc}
*/
protected function createRole(array $permissions, $rid = NULL, $name = NULL, $weight = NULL) {
// The parent method uses random strings by default, which may include HTML
// entities for the entity label. Since in this test the entity label is
// used to generate a link, and AssertContentTrait::assertLink() is not
// designed to deal with links potentially containing HTML entities this
// causes random failures. Use a random HTML safe string instead.
$name = $name ?: $this->randomMachineName();
return parent::createRole($permissions, $rid, $name, $weight);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.