You are here

protected function DependencyCalculatorTest::setUp in Dependency Calculation 8

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides KernelTestBase::setUp

File

tests/src/Kernel/DependencyCalculatorTest.php, line 61

Class

DependencyCalculatorTest
Class DependencyCalculatorTest.

Namespace

Drupal\Tests\depcalc\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('file', [
    'file_usage',
  ]);
  $this
    ->installSchema('comment', [
    'comment_entity_statistics',
  ]);
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installEntitySchema('path_alias');
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('file');
  $this
    ->installEntitySchema('block_content');
  $this
    ->installEntitySchema('comment');
  $this
    ->installEntitySchema('taxonomy_term');
  $this
    ->installEntitySchema('taxonomy_vocabulary');
  $this
    ->installConfig('depcalc_test');
  $this->calculator = Drupal::service('entity.dependency.calculator');

  // Create test user.

  /** @var \Drupal\Core\Entity\EntityRepository $entity_repository */
  $entity_repository = Drupal::service('entity.repository');
  $admin_role = $entity_repository
    ->loadEntityByUuid('user_role', '27202596-169e-4835-b9d4-c51ded9a03b8');
  $test_user = User::create([
    'name' => 'Admin',
    'roles' => [
      $admin_role
        ->id(),
    ],
    'uuid' => '2d666602-74c0-4d83-a6ef-d181fd562291',
  ]);
  $test_user
    ->save();

  // Create test taxonomy term.
  $test_taxonomy_term = Term::create([
    'name' => 'test-tag',
    'vid' => 'tags',
    'uuid' => 'e0fa273d-a5e4-4d22-81be-ab344fb8acd8',
  ]);
  $test_taxonomy_term
    ->save();

  // Create test image file.
  $test_image_file = File::create([
    'uri' => 'public://test.jpg',
    'uuid' => '4dcb20e3-b3cd-4b09-b157-fb3609b3fc93',
  ]);
  $test_image_file
    ->save();
}