You are here

protected function KernelTestBase::setUp in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/KernelTestBase.php \Drupal\Tests\video_embed_field\Kernel\KernelTestBase::setUp()

Overrides KernelTestBase::setUp

3 calls to KernelTestBase::setUp()
ConstraintTest::setUp in tests/src/Kernel/ConstraintTest.php
FilterTest::setUp in modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php
FormatterDependenciesTest::setUp in tests/src/Kernel/FormatterDependenciesTest.php
3 methods override KernelTestBase::setUp()
ConstraintTest::setUp in tests/src/Kernel/ConstraintTest.php
FilterTest::setUp in modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php
FormatterDependenciesTest::setUp in tests/src/Kernel/FormatterDependenciesTest.php

File

tests/src/Kernel/KernelTestBase.php, line 48

Class

KernelTestBase
A kernel test base.

Namespace

Drupal\Tests\video_embed_field\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema($this->entityTypeId);

  // Install image styles.
  $this
    ->installConfig([
    'image',
  ]);
  EntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityTypeId,
    'type' => 'video_embed_field',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => $this->entityTypeId,
    'field_name' => $this->fieldName,
    'bundle' => $this->entityTypeId,
  ])
    ->save();

  // Fake colorbox being enabled for the purposes of testing.
  $this->container
    ->get('module_handler')
    ->addModule('colorbox', NULL);

  // Use a HTTP mock which won't attempt to download anything.
  $this->container
    ->set('http_client', new MockHttpClient());

  // Shim in a service required from the colorbox module.
  $colorbox_mock = $this
    ->getMockBuilder('ColorboxAttachment')
    ->setMethods([
    'attach',
  ])
    ->getMock();
  $this->container
    ->set('colorbox.attachment', $colorbox_mock);
}