public function InsertColorboxTest::testLinkWidgetSetting in Insert 8.2
File
- modules/
insert_colorbox/ tests/ src/ FunctionalJavaScript/ InsertColorboxTest.php, line 87
Class
- InsertColorboxTest
- Tests Insert module's insert_colorbox module sub-module.
Namespace
Drupal\Tests\insert_colorbox\FunctionalJavascriptCode
public function testLinkWidgetSetting() {
$page = $this
->gotoInsertConfig();
$page
->findField($this
->t('Image style'))
->selectOption('0');
$this
->saveInsertConfig($page);
$fieldName = strtolower($this
->randomMachineName());
$this
->createImageField($fieldName, [
'alt_field' => '0',
]);
$this
->updateInsertSettings($fieldName, [
'styles' => [
'colorbox__thumbnail' => 'colorbox__thumbnail',
],
'default' => 'colorbox__thumbnail',
'link_image' => 'large',
]);
$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
->assertEquals(1, preg_match('!^<a href=".+/large/[^"]+" class="colorbox insert-colorbox"[^>]+>\\s*<img src=".+/thumbnail/[^>]+></a>$!', $body
->getValue()), 'Inserted colorbox link using the style link provided by Insert widget setting: ' . $body
->getValue());
}