protected function EntityAutocompleteElementFormTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\KernelTests\Core\Entity\Element\EntityAutocompleteElementFormTest::setUp()
- 9 core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\KernelTests\Core\Entity\Element\EntityAutocompleteElementFormTest::setUp()
File
- core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php, line 47
Class
- EntityAutocompleteElementFormTest
- Tests the EntityAutocomplete Form API element.
Namespace
Drupal\KernelTests\Core\Entity\Element
Code
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('entity_test_string_id');
User::create([
'uid' => 1,
'name' => 'user1',
])
->save();
Role::create([
'id' => 'test_role',
'label' => 'Can view test entities',
'permissions' => [
'view test entity',
],
])
->save();
$this->testUser = User::create([
'name' => 'foobar1',
'mail' => 'foobar1@example.com',
'roles' => [
'test_role',
],
]);
$this->testUser
->save();
\Drupal::service('current_user')
->setAccount($this->testUser);
$this->testAutocreateUser = User::create([
'name' => 'foobar2',
'mail' => 'foobar2@example.com',
]);
$this->testAutocreateUser
->save();
for ($i = 1; $i < 3; $i++) {
$entity = EntityTest::create([
'name' => $this
->randomMachineName(),
]);
$entity
->save();
$this->referencedEntities[] = $entity;
}
for ($i = 0; $i < 2; $i++) {
$entity = EntityTestStringId::create([
'name' => $this
->randomMachineName(),
'id' => $this
->randomMachineName() . '&</\\:?',
]);
$entity
->save();
$this->referencedEntities[] = $entity;
}
}