You are here

protected function EntityEmbedDisplayManagerTest::setUp in Entity Embed 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/EntityEmbedDisplayManagerTest.php, line 61

Class

EntityEmbedDisplayManagerTest
@coversDefaultClass \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager @group entity_embed

Namespace

Drupal\Tests\entity_embed\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->imageButton = $this->container
    ->get('entity_type.manager')
    ->getStorage('embed_button')
    ->create([
    'label' => 'Image Embed',
    'id' => 'image_embed',
    'type_id' => 'entity',
    'type_settings' => [
      'entity_type' => 'file',
      'display_plugins' => [
        'image:image',
      ],
      'entity_browser' => '',
      'entity_browser_settings' => [
        'display_review' => FALSE,
      ],
    ],
    'icon_uuid' => NULL,
  ]);
  $this->imageButton
    ->save();

  // Create a sample image to embed.
  $entity_embed_path = $this->container
    ->get('module_handler')
    ->getModule('entity_embed')
    ->getPath();
  \Drupal::service('file_system')
    ->copy($entity_embed_path . '/js/plugins/drupalentity/entity.png', 'public://example1.png');

  // Resize the test image so that it will be scaled down during token
  // replacement.
  $this->image1 = $this->container
    ->get('image.factory')
    ->get('public://example1.png');
  $this->image1
    ->resize(500, 500);
  $this->image1
    ->save();
  $this->image = $this->container
    ->get('entity_type.manager')
    ->getStorage('file')
    ->create([
    'uri' => 'public://example1.png',
    'status' => 1,
  ]);
  $this->image
    ->save();
  $this->invalidImage = $this->container
    ->get('entity_type.manager')
    ->getStorage('file')
    ->create([
    'uri' => 'public://nonexistentimage.jpg',
    'filename' => 'nonexistentimage.jpg',
    'status' => 1,
  ]);
  $this->invalidImage
    ->save();
  $this->entityEmbedDisplayManager = $this->container
    ->get('plugin.manager.entity_embed.display');
}