comparison core/modules/image/src/Tests/ImageFieldValidateTest.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
154 'min_resolution' => $min_resolution['width'] . 'x' . $min_resolution['height'], 154 'min_resolution' => $min_resolution['width'] . 'x' . $min_resolution['height'],
155 'alt_field' => 0, 155 'alt_field' => 0,
156 ]; 156 ];
157 } 157 }
158 158
159 /**
160 * Test the validation message is displayed only once for ajax uploads.
161 */
162 public function testAJAXValidationMessage() {
163 $field_name = strtolower($this->randomMachineName());
164 $this->createImageField($field_name, 'article', ['cardinality' => -1]);
165
166 $this->drupalGet('node/add/article');
167 /** @var \Drupal\file\FileInterface[] $text_files */
168 $text_files = $this->drupalGetTestFiles('text');
169 $text_file = reset($text_files);
170 $edit = [
171 'files[' . $field_name . '_0][]' => $this->container->get('file_system')->realpath($text_file->uri),
172 'title[0][value]' => $this->randomMachineName(),
173 ];
174 $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_0_upload_button');
175 $elements = $this->xpath('//div[contains(@class, :class)]', [
176 ':class' => 'messages--error',
177 ]);
178 $this->assertEqual(count($elements), 1, 'Ajax validation messages are displayed once.');
179 }
180
159 } 181 }