protected function TextFormatElementFormTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php \Drupal\Tests\filter\Kernel\TextFormatElementFormTest::setUp()
- 9 core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php \Drupal\Tests\filter\Kernel\TextFormatElementFormTest::setUp()
Sets up the test.
File
- core/
modules/ filter/ tests/ src/ Kernel/ TextFormatElementFormTest.php, line 42
Class
- TextFormatElementFormTest
- Tests PathElement validation and conversion functionality.
Namespace
Drupal\Tests\filter\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installSchema('system', [
'sequences',
]);
$this
->installConfig([
'filter',
'filter_test',
]);
// Create user 1 so that the user created later in the test has a different
// user ID.
// @todo Remove in https://www.drupal.org/node/540008.
User::create([
'uid' => 1,
'name' => 'user1',
])
->save();
/** @var \Drupal\Core\Render\ElementInfoManager $manager */
$manager = \Drupal::service('plugin.manager.element_info');
$manager
->clearCachedDefinitions();
$manager
->getDefinitions();
/** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
$filter_test_format = FilterFormat::load('filter_test');
$full_html_format = FilterFormat::load('full_html');
$filtered_html_format = FilterFormat::load('filtered_html');
/** @var \Drupal\user\RoleInterface $role */
$role = Role::create([
'id' => 'admin',
'label' => 'admin',
]);
$role
->grantPermission($filter_test_format
->getPermissionName());
$role
->grantPermission($full_html_format
->getPermissionName());
$role
->grantPermission($filtered_html_format
->getPermissionName());
$role
->save();
$this->testUser = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
]);
$this->testUser
->addRole($role
->id());
$this->testUser
->save();
\Drupal::service('current_user')
->setAccount($this->testUser);
}