public function InsertImageTest::testUpdatingAltAttribute in Insert 8.2
File
- tests/
src/ FunctionalJavaScript/ InsertImageTest.php, line 443
Class
- InsertImageTest
- Tests Insert module's image insert capability.
Namespace
Drupal\Tests\insert\FunctionalJavascriptCode
public function testUpdatingAltAttribute() {
$fieldName = strtolower($this
->randomMachineName());
$this
->createImageField($fieldName);
$this
->updateInsertSettings($fieldName, [
'styles' => [
'image' => 'image',
],
'default' => 'image',
]);
$images = $this
->drupalGetTestFiles('image');
$this
->drupalGet('node/add/article');
$page = $this
->getSession()
->getPage();
$page
->attachFileToField('files[' . $fieldName . '_0]', \Drupal::service('file_system')
->realpath($images[0]->uri));
$this
->assertSession()
->waitForField($fieldName . '[0][fids]');
$body = $page
->findField('body[0][value]');
$altField = $page
->findField($fieldName . '[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());
}