public function ImageFieldValidateTest::testAJAXValidationMessage in Drupal 8
Same name and namespace in other branches
- 9 core/modules/image/tests/src/FunctionalJavascript/ImageFieldValidateTest.php \Drupal\Tests\image\FunctionalJavascript\ImageFieldValidateTest::testAJAXValidationMessage()
Test the validation message is displayed only once for ajax uploads.
File
- core/
modules/ image/ tests/ src/ FunctionalJavascript/ ImageFieldValidateTest.php, line 23
Class
- ImageFieldValidateTest
- Tests validation functions such as min/max resolution.
Namespace
Drupal\Tests\image\FunctionalJavascriptCode
public function testAJAXValidationMessage() {
$field_name = strtolower($this
->randomMachineName());
$this
->createImageField($field_name, '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');
$elements = $this
->xpath('//div[contains(@class, :class)]', [
':class' => 'messages--error',
]);
$this
->assertCount(1, $elements, 'Ajax validation messages are displayed once.');
}