public function InsertFileTest::testAutomaticStyle in Insert 8.2
File
- tests/
src/ FunctionalJavaScript/ InsertFileTest.php, line 111
Class
- InsertFileTest
- Tests Insert module's generic file insert capability.
Namespace
Drupal\Tests\insert\FunctionalJavascriptCode
public function testAutomaticStyle() {
$fieldName = strtolower($this
->randomMachineName());
$this
->createFileField($fieldName);
$this
->updateInsertSettings($fieldName, [
'styles' => [
'insert__auto' => 'insert__auto',
],
'default' => 'insert__auto',
]);
$this
->drupalGet('node/add/article');
$page = $this
->getSession()
->getPage();
$files = $this
->drupalGetTestFiles('text');
$page
->attachFileToField('files[' . $fieldName . '_0]', \Drupal::service('file_system')
->realpath($files[0]->uri));
$this
->assertSession()
->waitForField($fieldName . '[0][fids]');
$page
->findButton('Insert')
->click();
$body = $page
->findField('body[0][value]');
$this
->assertEquals(1, preg_match('!^<a[^>]+>[^<]+</a>!', $body
->getValue()), 'Correctly inserted using AUTOMATIC style: ' . $body
->getValue());
}