You are here

public function InsertColorboxTest::testGallery in Insert 8.2

File

modules/insert_colorbox/tests/src/FunctionalJavaScript/InsertColorboxTest.php, line 49

Class

InsertColorboxTest
Tests Insert module's insert_colorbox module sub-module.

Namespace

Drupal\Tests\insert_colorbox\FunctionalJavascript

Code

public function testGallery() {
  $page = $this
    ->gotoInsertConfig();
  $page
    ->findField($this
    ->t('Per page gallery'))
    ->click();
  $this
    ->saveInsertConfig($page);
  $fieldName = strtolower($this
    ->randomMachineName());
  $this
    ->createImageField($fieldName, [
    'alt_field' => '0',
  ]);
  $this
    ->updateInsertSettings($fieldName, [
    'styles' => [
      'colorbox__thumbnail' => 'colorbox__thumbnail',
    ],
    'default' => 'colorbox__thumbnail',
  ]);
  $this
    ->drupalGet('node/add/article');
  $page = $this
    ->getSession()
    ->getPage();
  $images = $this
    ->drupalGetTestFiles('image');
  $page
    ->attachFileToField('files[' . $fieldName . '_0]', \Drupal::service('file_system')
    ->realpath($images[0]->uri));
  $this
    ->assertSession()
    ->waitForField($fieldName . '[0][fids]');
  $page
    ->findButton('Insert')
    ->click();
  $body = $page
    ->findField('body[0][value]');
  $this
    ->assertTrue(strpos($body
    ->getValue(), 'class="colorbox insert-colorbox"'), 'Verified colorbox classes being set: ' . $body
    ->getValue());
  $this
    ->assertTrue(strpos($body
    ->getValue(), 'data-colorbox-gallery="gallery-all-'), 'Verified data-colorbox-gallery attribute being set: ' . $body
    ->getValue());
}