diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php index 5a7429c..a6d50e1 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php @@ -241,7 +241,7 @@ protected function doTestAuthoringInfo() { 'content_translation[created]' => '19/11/1978', ); $this->drupalPostForm($entity->urlInfo('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode)); - $this->assertTrue($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.'); + $this->assertTrue($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]', array(':class' => ' messages--error ')), 'Invalid values generate a form error message.'); $metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode)); $this->assertEqual($metadata->getAuthor()->id(), $values[$langcode]['uid'], 'Translation author correctly kept.'); $this->assertEqual($metadata->getCreatedTime(), $values[$langcode]['created'], 'Translation date correctly kept.'); diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php index 51d7402..ea8c0c9 100644 --- a/core/modules/file/src/Tests/FileFieldValidateTest.php +++ b/core/modules/file/src/Tests/FileFieldValidateTest.php @@ -34,7 +34,8 @@ function testRequired() { $edit = array(); $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); - $this->assertRaw(t('!title field is required.', array('!title' => $field->getLabel())), 'Node save failed when required file field was empty.'); + $this->assertText('1 error has been found: Choose a file', 'Node save failed when required file field was empty.'); + $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', array(':class' => ' messages--error '))), 'There is one link in the error message.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); @@ -55,7 +56,8 @@ function testRequired() { $edit = array(); $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); - $this->assertRaw(t('!title field is required.', array('!title' => $field->getLabel())), 'Node save failed when required multiple value file field was empty.'); + $this->assertText('1 error has been found: Choose a file', 'Node save failed when required multiple value file field was empty.'); + $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', array(':class' => ' messages--error '))), 'There is one link in the error message.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); diff --git a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php index 2769506..d785e27 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php @@ -35,7 +35,7 @@ public function testDisplayErrorMessages() { ->with('this missing element is invalid', 'error'); $form_error_handler->expects($this->at(1)) ->method('drupalSetMessage') - ->with('2 errors have been found: Test 1, Test 2', 'error'); + ->with('3 errors have been found: Test 1, Test 2, Test 3', 'error'); $form = [ '#parents' => [], @@ -44,15 +44,30 @@ public function testDisplayErrorMessages() { '#type' => 'textfield', '#title' => 'Test 1', '#parents' => ['test1'], + '#name' => 'test1', + '#id' => 'edit-test1', ]; $form['test2'] = [ '#type' => 'textfield', '#title' => 'Test 2', '#parents' => ['test2'], + '#name' => 'test2', + '#id' => 'edit-test2', + ]; + $form['fieldset'] = [ + '#parents' => ['fieldset'], + 'test3' => array( + '#type' => 'textfield', + '#title' => 'Test 3', + '#parents' => ['fieldset', 'test3'], + '#name' => 'test3', + '#id' => 'edit-test3', + ), ]; $form_state = new FormState(); $form_state->setErrorByName('test1', 'invalid'); $form_state->setErrorByName('test2', 'invalid'); + $form_state->setErrorByName('fieldset][test3', 'invalid'); $form_state->setErrorByName('missing_element', 'this missing element is invalid'); $form_error_handler->handleFormErrors($form, $form_state); $this->assertSame('invalid', $form['test1']['#errors']); @@ -75,6 +90,8 @@ public function testSetElementErrorsFromFormState() { '#type' => 'textfield', '#title' => 'Test', '#parents' => ['test'], + '#name' => 'test', + '#id' => 'edit-test', ]; $form_state = new FormState(); $form_state->setErrorByName('test', 'invalid');