class EntityOperationsTest
Same name in this branch
- 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
Same name and namespace in other branches
- 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
- 9 core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
- 9 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
- main core/modules/content_moderation/tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\content_moderation\Kernel\EntityOperationsTest
- main core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php \Drupal\Tests\system\Functional\Entity\EntityOperationsTest
- main core/modules/system/tests/src/Kernel/Entity/EntityOperationsTest.php \Drupal\Tests\system\Kernel\Entity\EntityOperationsTest
Tests that operations can be injected from the hook.
Attributes
#[Group('Entity')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\Entity\EntityOperationsTest uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of EntityOperationsTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityOperationsTest.php, line 16
Namespace
Drupal\Tests\system\Kernel\EntityView source
class EntityOperationsTest extends KernelTestBase {
use UserCreationTrait {
createUser as drupalCreateUser;
}
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test',
'system',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
// Create and log in user.
$this->setCurrentUser($this->drupalCreateUser([
'administer permissions',
]));
}
/**
* Checks that hook_entity_operation_alter() can add an operation.
*
* @see entity_test_entity_operation_alter()
*/
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.