You are here

protected function ColorboxJavascriptTest::setUp in Colorbox 8

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/ColorboxJavascriptTest.php, line 141

Class

ColorboxJavascriptTest
Test the colorbox JavaScript.

Namespace

Drupal\Tests\colorbox\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this
    ->createContentType([
    'type' => 'page',
  ]);
  FieldStorageConfig::create([
    'field_name' => 'field_test_image',
    'entity_type' => 'node',
    'type' => 'image',
    'settings' => [],
    'cardinality' => 3,
  ])
    ->save();
  $field_config = FieldConfig::create([
    'field_name' => 'field_test_image',
    'label' => 'Colorbox Field',
    'entity_type' => 'node',
    'bundle' => 'page',
    'required' => TRUE,
    'settings' => [],
  ]);
  $field_config
    ->save();
  \Drupal::entityTypeManager()
    ->getStorage('entity_view_display')
    ->load('node.page.default')
    ->setComponent('field_test_image', [
    'type' => 'colorbox',
    'settings' => [],
  ])
    ->save();
  \Drupal::service('file_system')
    ->copy(__DIR__ . '/../../../images/admin/colorbox_example_1.png', 'public://test.png');
  $file_a = File::create([
    'uri' => 'public://test.png',
    'filename' => 'test.png',
  ]);
  $file_a
    ->save();
  $file_b = File::create([
    'uri' => 'public://test.png',
    'filename' => 'test.png',
  ]);
  $file_b
    ->save();
  $this->node = $this
    ->createNode([
    'type' => 'page',
    'field_test_image' => [
      [
        'target_id' => $file_a
          ->id(),
        'alt' => 'Image alt 1',
        'title' => 'Image title 1',
      ],
      [
        'target_id' => $file_b
          ->id(),
        'alt' => 'Image alt 2',
        'title' => 'Image title 2',
      ],
    ],
  ]);
}