comparison core/modules/file/src/Tests/FileFieldValidateTest.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
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
185 $this->removeNodeFile($nid); 185 $this->removeNodeFile($nid);
186 $this->assertNoText('Only files with the following extensions are allowed: txt.'); 186 $this->assertNoText('Only files with the following extensions are allowed: txt.');
187 $this->assertText('Article ' . $node->getTitle() . ' has been updated.'); 187 $this->assertText('Article ' . $node->getTitle() . ' has been updated.');
188 } 188 }
189 189
190 /**
191 * Test the validation message is displayed only once for ajax uploads.
192 */
193 public function testAJAXValidationMessage() {
194 $field_name = strtolower($this->randomMachineName());
195 $this->createFileField($field_name, 'node', 'article');
196
197 $this->drupalGet('node/add/article');
198 /** @var \Drupal\file\FileInterface $image_file */
199 $image_file = $this->getTestFile('image');
200 $edit = [
201 'files[' . $field_name . '_0]' => $this->container->get('file_system')->realpath($image_file->getFileUri()),
202 'title[0][value]' => $this->randomMachineName(),
203 ];
204 $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_0_upload_button');
205 $elements = $this->xpath('//div[contains(@class, :class)]', [
206 ':class' => 'messages--error',
207 ]);
208 $this->assertEqual(count($elements), 1, 'Ajax validation messages are displayed once.');
209 }
210
190 } 211 }