public function InsertColorboxTest::testWithoutGallery in Insert 8.2
File
- modules/
insert_colorbox/ tests/ src/ FunctionalJavaScript/ InsertColorboxTest.php, line 15
Class
- InsertColorboxTest
- Tests Insert module's insert_colorbox module sub-module.
Namespace
Drupal\Tests\insert_colorbox\FunctionalJavascriptCode
public function testWithoutGallery() {
$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
->assertEquals(0, preg_match('!data-colorbox-gallery="[^"]+"!', $body
->getValue()), 'Verified data-colorbox-gallery attribute being empty: ' . $body
->getValue());
}