You are here

protected function EntityAutocompleteElementFormTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\system\Tests\Entity\Element\EntityAutocompleteElementFormTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides EntityUnitTestBase::setUp

File

core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php, line 50
Contains \Drupal\system\Tests\Entity\Element\EntityAutocompleteElementFormTest.

Class

EntityAutocompleteElementFormTest
Tests the EntityAutocomplete Form API element.

Namespace

Drupal\system\Tests\Entity\Element

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('system', [
    'router',
    'key_value_expire',
  ]);
  \Drupal::service('router.builder')
    ->rebuild();
  $this->testUser = User::create(array(
    'name' => 'foobar1',
    'mail' => 'foobar1@example.com',
  ));
  $this->testUser
    ->save();
  \Drupal::service('current_user')
    ->setAccount($this->testUser);
  $this->testAutocreateUser = User::create(array(
    'name' => 'foobar2',
    'mail' => 'foobar2@example.com',
  ));
  $this->testAutocreateUser
    ->save();
  for ($i = 1; $i < 3; $i++) {
    $entity = EntityTest::create(array(
      'name' => $this
        ->randomMachineName(),
    ));
    $entity
      ->save();
    $this->referencedEntities[] = $entity;
  }
}