function ImageFieldValidateTest::testAJAXValidationMessage
Same name in other branches
- 9 core/modules/image/tests/src/FunctionalJavascript/ImageFieldValidateTest.php \Drupal\Tests\image\FunctionalJavascript\ImageFieldValidateTest::testAJAXValidationMessage()
- 8.9.x core/modules/image/tests/src/FunctionalJavascript/ImageFieldValidateTest.php \Drupal\Tests\image\FunctionalJavascript\ImageFieldValidateTest::testAJAXValidationMessage()
- 10 core/modules/image/tests/src/FunctionalJavascript/ImageFieldValidateTest.php \Drupal\Tests\image\FunctionalJavascript\ImageFieldValidateTest::testAJAXValidationMessage()
Tests the validation message is displayed only once for ajax uploads.
File
-
core/
modules/ image/ tests/ src/ FunctionalJavascript/ ImageFieldValidateTest.php, line 25
Class
- ImageFieldValidateTest
- Tests validation functions such as min/max dimensions.
Namespace
Drupal\Tests\image\FunctionalJavascriptCode
public function testAJAXValidationMessage() : void {
$field_name = $this->randomMachineName();
$this->createImageField($field_name, 'node', 'article', [
'cardinality' => -1,
]);
$this->drupalGet('node/add/article');
/** @var \Drupal\file\FileInterface[] $text_files */
$text_files = $this->drupalGetTestFiles('text');
$text_file = reset($text_files);
$field = $this->getSession()
->getPage()
->findField('files[' . $field_name . '_0][]');
$field->attachFile($this->container
->get('file_system')
->realpath($text_file->uri));
$this->assertSession()
->waitForElement('css', '.messages--error');
// Verify that Ajax validation messages are displayed only once.
$this->assertSession()
->elementsCount('xpath', '//div[contains(@class, "messages--error")]', 1);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.