public function InsertImageWidgetTest::testUpdatingAltAttribute in Insert 8
File
- tests/
src/ FunctionalJavaScript/ InsertImageWidgetTest.php, line 352
Class
- InsertImageWidgetTest
- @group insert
Namespace
Drupal\Tests\insert\FunctionalJavascriptCode
public function testUpdatingAltAttribute() {
$field_name = strtolower($this
->randomMachineName());
$this
->createImageField($field_name, 'article', [], [], [
'insert_default' => 'image',
'insert_styles' => [
'thumbnail' => 'thumbnail',
],
]);
$images = $this
->drupalGetTestFiles('image');
$this
->drupalGet('node/add/article');
$page = $this
->getSession()
->getPage();
$page
->attachFileToField('files[' . $field_name . '_0]', \Drupal::service('file_system')
->realpath($images[0]->uri));
$this
->assertSession()
->waitForField($field_name . '[0][fids]');
$body = $page
->findField('body[0][value]');
$altField = $page
->findField($field_name . '[0][alt]');
$altField
->setValue('initial');
$page
->findButton('Insert')
->click();
$this
->assertTrue(strpos($body
->getValue(), 'alt="initial"') !== FALSE, 'Verified initial string set on alt attribute: ' . $body
->getValue());
$altField
->setValue('altered');
$this
->assertTrue(strpos($body
->getValue(), 'alt="altered"') !== FALSE, 'Verified altered string set on alt attribute: ' . $body
->getValue());
}