Commit 0451a6d7 authored by webchick's avatar webchick

Issue #2083811 by yched, plach: Remove langcode nesting for fields in entity structures.

parent 47bc6fd2
......@@ -305,10 +305,9 @@ public function validate(array $form, array &$form_state) {
// Map errors back to form elements.
if ($violations) {
foreach ($violations as $field_name => $field_violations) {
$langcode = field_is_translatable($entity_type , field_info_field($entity_type, $field_name)) ? $entity_langcode : Language::LANGCODE_NOT_SPECIFIED;
$field_state = field_form_get_state($form['#parents'], $field_name, $langcode, $form_state);
$field_state = field_form_get_state($form['#parents'], $field_name, $form_state);
$field_state['constraint_violations'] = $field_violations;
field_form_set_state($form['#parents'], $field_name, $langcode, $form_state, $field_state);
field_form_set_state($form['#parents'], $field_name, $form_state, $field_state);
}
field_invoke_method('flagErrors', _field_invoke_widget_target($form_state['form_display']), $entity, $form, $form_state);
......@@ -339,7 +338,6 @@ public function submit(array $form, array &$form_state) {
form_state_values_clean($form_state);
$this->updateFormLangcode($form_state);
$this->submitEntityLanguage($form, $form_state);
$this->entity = $this->buildEntity($form, $form_state);
return $this->entity;
}
......@@ -414,42 +412,6 @@ protected function updateFormLangcode(array &$form_state) {
}
}
/**
* Handle possible entity language changes.
*
* @param array $form
* An associative array containing the structure of the form.
* @param array $form_state
* A reference to a keyed array containing the current state of the form.
*/
protected function submitEntityLanguage(array $form, array &$form_state) {
$entity = $this->entity;
$entity_type = $entity->entityType();
if (field_has_translation_handler($entity_type)) {
// If we are editing the default language values, we use the submitted
// entity language as the new language for fields to handle any language
// change. Otherwise the current form language is the proper value, since
// in this case it is not supposed to change.
$current_langcode = $this->isDefaultFormLangcode($form_state) ? $form_state['values']['langcode'] : $this->getFormLangcode($form_state);
foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
$field = $instance->getField();
$field_name = $field->name;
if (isset($form[$field_name]['#language'])) {
$previous_langcode = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_langcode != $current_langcode) {
$form_state['values'][$field_name][$current_langcode] = $form_state['values'][$field_name][$previous_langcode];
$form_state['values'][$field_name][$previous_langcode] = array();
}
}
}
}
}
/**
* Implements \Drupal\Core\Entity\EntityFormControllerInterface::buildEntity().
*/
......
......@@ -37,16 +37,6 @@ public function form(array $form, array &$form_state) {
return $form;
}
/**
* Overrides EntityFormController::submitEntityLanguage().
*/
protected function submitEntityLanguage(array $form, array &$form_state) {
// Nothing to do here, as original field values are always stored with
// Language::LANGCODE_DEFAULT language.
// @todo Delete this method when merging EntityFormControllerNG with
// EntityFormController.
}
/**
* Overrides EntityFormController::buildEntity().
*/
......
......@@ -356,12 +356,11 @@ function getHtmlEntitiesSample() {
* (optional) The number of nodes to generate. Defaults to five.
*/
function createSampleNodes($count = 5) {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
// Post $count article nodes.
for ($i = 0; $i < $count; $i++) {
$edit = array();
$edit['title'] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$edit['body[0][value]'] = $this->randomName();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
}
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\custom_block\Tests;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\Language;
/**
* Tests creating and saving a block.
......@@ -49,9 +48,8 @@ protected function setUp() {
public function testCustomBlockCreation() {
// Create a block.
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $this->randomName(8);
$edit["block_body[$langcode][0][value]"] = $this->randomName(16);
$edit['block_body[0][value]'] = $this->randomName(16);
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Check that the Basic block has been created.
......@@ -84,9 +82,8 @@ public function testCustomBlockCreation() {
*/
public function testDefaultCustomBlockCreation() {
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $this->randomName(8);
$edit["block_body[$langcode][0][value]"] = $this->randomName(16);
$edit['block_body[0][value]'] = $this->randomName(16);
// Don't pass the custom block type in the url so the default is forced.
$this->drupalPostForm('block/add', $edit, t('Save'));
......@@ -145,10 +142,9 @@ public function testFailedBlockCreation() {
public function testBlockDelete() {
// Create a block.
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $this->randomName(8);
$body = $this->randomName(16);
$edit["block_body[$langcode][0][value]"] = $body;
$edit['block_body[0][value]'] = $body;
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
// Place the block.
......@@ -179,10 +175,9 @@ public function testBlockDelete() {
// Create another block and force the plugin cache to flush.
$edit2 = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit2['info'] = $this->randomName(8);
$body2 = $this->randomName(16);
$edit2["block_body[$langcode][0][value]"] = $body2;
$edit2['block_body[0][value]'] = $body2;
$this->drupalPostForm('block/add/basic', $edit2, t('Save'));
$this->assertNoRaw('Error message');
......@@ -192,7 +187,7 @@ public function testBlockDelete() {
$edit3 = array();
$edit3['info'] = $this->randomName(8);
$body = $this->randomName(16);
$edit3["block_body[$langcode][0][value]"] = $body;
$edit3['block_body[0][value]'] = $body;
$this->drupalPostForm('block/add/basic', $edit3, t('Save'));
// Show the delete confirm form.
......
......@@ -96,8 +96,8 @@ public function testBlockFields() {
$this->drupalGet('block/add/link');
$edit = array(
'info' => $this->randomName(8),
$this->field['field_name'] . '[und][0][url]' => 'http://example.com',
$this->field['field_name'] . '[und][0][title]' => 'Example.com'
$this->field['field_name'] . '[0][url]' => 'http://example.com',
$this->field['field_name'] . '[0][title]' => 'Example.com'
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$block = entity_load('custom_block', 1);
......
......@@ -7,7 +7,6 @@
namespace Drupal\custom_block\Tests;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
......@@ -64,9 +63,8 @@ public function testListing() {
$this->clickLink($link_text);
$this->assertResponse(200);
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $label;
$edit["block_body[$langcode][0][value]"] = $this->randomName(16);
$edit['block_body[0][value]'] = $this->randomName(16);
$this->drupalPostForm(NULL, $edit, t('Save'));
// Confirm that once the user returns to the listing, the text of the label
......
......@@ -31,9 +31,8 @@ public static function getInfo() {
public function testPageEdit() {
$this->drupalLogin($this->adminUser);
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = 'info';
$body_key = "block_body[$langcode][0][value]";
$body_key = 'block_body[0][value]';
// Create block to edit.
$edit = array();
$edit['info'] = drupal_strtolower($this->randomName(8));
......
......@@ -243,9 +243,8 @@ function createBookNode($book_nid, $parent = NULL) {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
if ($parent !== NULL) {
......
......@@ -109,7 +109,7 @@ function testLoading() {
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-body-und-0-value"]');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
$this->assertTrue(isset($settings['ajaxPageState']['js']['core/modules/ckeditor/js/ckeditor.js']), 'CKEditor glue JS is present.');
$this->assertTrue(isset($settings['ajaxPageState']['js']['core/assets/vendor/ckeditor/ckeditor.js']), 'CKEditor lib JS is present.');
......@@ -147,7 +147,7 @@ protected function getThingsToCheck() {
// Editor.module's JS present.
isset($settings['ajaxPageState']['js']['core/modules/editor/js/editor.js']),
// Body field.
$this->xpath('//textarea[@id="edit-body-und-0-value"]'),
$this->xpath('//textarea[@id="edit-body-0-value"]'),
// Format selector.
$this->xpath('//select[contains(@class, "filter-list")]'),
);
......
......@@ -7,8 +7,6 @@
namespace Drupal\comment\Tests;
use Drupal\Core\Language\Language;
/**
* Tests anonymous commenting.
*/
......@@ -68,12 +66,11 @@ function testAnonymous() {
$this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.');
// Ensure anonymous users cannot post in the name of registered users.
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
'name' => $this->admin_user->getUsername(),
'mail' => $this->randomName() . '@example.com',
'subject' => $this->randomName(),
"comment_body[$langcode][0][value]" => $this->randomName(),
'comment_body[0][value]' => $this->randomName(),
);
$this->drupalPostForm('comment/reply/' . $this->node->id(), $edit, t('Save'));
$this->assertText(t('The name you used belongs to a registered user.'));
......@@ -141,7 +138,7 @@ function testAnonymous() {
$this->drupalGet('comment/reply/' . $this->node->id());
$this->assertText('You are not authorized to post comments', 'Error attempting to post comment.');
$this->assertNoFieldByName('subject', '', 'Subject field not found.');
$this->assertNoFieldByName("comment_body[$langcode][0][value]", '', 'Comment field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
......@@ -161,7 +158,7 @@ function testAnonymous() {
$this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject', '', 'Subject field found.');
$this->assertFieldByName("comment_body[$langcode][0][value]", '', 'Comment field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');
$this->drupalGet('comment/reply/' . $this->node->id() . '/' . $anonymous_comment3->id());
$this->assertText('You are not authorized to view comments', 'Error attempting to post reply.');
......
......@@ -111,7 +111,7 @@ function testCommentFormat() {
// Post a comment without an explicit subject.
$this->drupalLogin($this->web_user);
$edit = array('comment_body[und][0][value]' => $this->randomName(8));
$edit = array('comment_body[0][value]' => $this->randomName(8));
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Save'));
}
}
......@@ -7,8 +7,6 @@
namespace Drupal\comment\Tests;
use Drupal\Core\Language\Language;
/**
* Tests the comment module administrative and end-user-facing interfaces.
*/
......@@ -26,7 +24,6 @@ public static function getInfo() {
* Tests the comment interface.
*/
function testCommentInterface() {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
// Set comments to have subject and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
......@@ -144,7 +141,7 @@ function testCommentInterface() {
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/' . $this->node->id());
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
$this->assertField('edit-comment-body-' . $langcode . '-0-value', 'Comment body field found.');
$this->assertField('edit-comment-body-0-value', 'Comment body field found.');
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
......
......@@ -7,7 +7,6 @@
namespace Drupal\comment\Tests;
use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
......@@ -90,14 +89,12 @@ function testCommentLanguage() {
// language and interface language do not influence comment language, as
// only content language has to.
foreach (language_list() as $node_langcode => $node_language) {
$langcode_not_specified = Language::LANGCODE_NOT_SPECIFIED;
// Create "Article" content.
$title = $this->randomName();
$edit = array(
"title" => $title,
"body[$langcode_not_specified][0][value]" => $this->randomName(),
"langcode" => $node_langcode,
'title' => $title,
'body[0][value]' => $this->randomName(),
'langcode' => $node_langcode,
);
$this->drupalPostForm("node/add/article", $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($title);
......@@ -109,7 +106,7 @@ function testCommentLanguage() {
$comment_values[$node_langcode][$langcode] = $this->randomName();
$edit = array(
'subject' => $this->randomName(),
"comment_body[$langcode][0][value]" => $comment_values[$node_langcode][$langcode],
'comment_body[0][value]' => $comment_values[$node_langcode][$langcode],
);
$this->drupalPostForm($prefix . 'node/' . $node->id(), $edit, t('Preview'));
$this->drupalPostForm(NULL, $edit, t('Save'));
......
......@@ -9,8 +9,6 @@
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Language\Language;
/**
* Tests previewing comments.
*/
......@@ -61,8 +59,6 @@ function setUp() {
* Tests comment preview.
*/
function testCommentPreview() {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
// As admin user, configure comment settings.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_OPTIONAL);
......@@ -77,23 +73,23 @@ function testCommentPreview() {
$test_signature = $this->randomName();
$edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
$image = current($this->drupalGetTestFiles('image'));
$edit['files[user_picture_und_0]'] = drupal_realpath($image->uri);
$edit['files[user_picture_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('user/' . $this->web_user->id() . '/edit', $edit, t('Save'));
// As the web user, fill in the comment form and preview the comment.
$edit = array();
$edit['subject'] = $this->randomName(8);
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$edit['comment_body[0][value]'] = $this->randomName(16);
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".');
$this->assertText($edit['subject'], 'Subject displayed.');
$this->assertText($edit['comment_body[' . $langcode . '][0][value]'], 'Comment displayed.');
$this->assertText($edit['comment_body[0][value]'], 'Comment displayed.');
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], 'Comment field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
// Check that the signature is displaying with the correct text format.
$this->assertLink($test_signature);
......@@ -106,7 +102,6 @@ function testCommentPreview() {
* Tests comment edit, preview, and save.
*/
function testCommentEditPreviewSave() {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_OPTIONAL);
......@@ -117,7 +112,7 @@ function testCommentEditPreviewSave() {
$edit = array();
$date = new DrupalDateTime('2008-03-02 17:23');
$edit['subject'] = $this->randomName(8);
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$edit['comment_body[0][value]'] = $this->randomName(16);
$edit['name'] = $web_user->getUsername();
$edit['date[date]'] = $date->format('Y-m-d');
$edit['date[time]'] = $date->format('H:i:s');
......@@ -125,19 +120,19 @@ function testCommentEditPreviewSave() {
$expected_text_date = format_date($raw_date);
$expected_form_date = $date->format('Y-m-d');
$expected_form_time = $date->format('H:i:s');
$comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE);
$comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[0][value]'], TRUE);
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, t('Preview'));
// Check that the preview is displaying the subject, comment, author and date correctly.
$this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".');
$this->assertText($edit['subject'], 'Subject displayed.');
$this->assertText($edit['comment_body[' . $langcode . '][0][value]'], 'Comment displayed.');
$this->assertText($edit['comment_body[0][value]'], 'Comment displayed.');
$this->assertText($edit['name'], 'Author displayed.');
$this->assertText($expected_text_date, 'Date displayed.');
// Check that the subject, comment, author and date fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], 'Comment field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertFieldByName('name', $edit['name'], 'Author field displayed.');
$this->assertFieldByName('date[date]', $edit['date[date]'], 'Date field displayed.');
$this->assertFieldByName('date[time]', $edit['date[time]'], 'Time field displayed.');
......@@ -149,7 +144,7 @@ function testCommentEditPreviewSave() {
// Check that the comment fields are correct after loading the saved comment.
$this->drupalGet('comment/' . $comment->id() . '/edit');
$this->assertFieldByName('subject', $edit['subject'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], 'Comment field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertFieldByName('name', $edit['name'], 'Author field displayed.');
$this->assertFieldByName('date[date]', $expected_form_date, 'Date field displayed.');
$this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.');
......@@ -157,7 +152,7 @@ function testCommentEditPreviewSave() {
// Submit the form using the displayed values.
$displayed = array();
$displayed['subject'] = (string) current($this->xpath("//input[@id='edit-subject']/@value"));
$displayed['comment_body[' . $langcode . '][0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-" . $langcode . "-0-value']"));
$displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']"));
$displayed['name'] = (string) current($this->xpath("//input[@id='edit-name']/@value"));
$displayed['date[date]'] = (string) current($this->xpath("//input[@id='edit-date-date']/@value"));
$displayed['date[time]'] = (string) current($this->xpath("//input[@id='edit-date-time']/@value"));
......@@ -166,10 +161,9 @@ function testCommentEditPreviewSave() {
// Check that the saved comment is still correct.
$comment_loaded = comment_load($comment->id(), TRUE);
$this->assertEqual($comment_loaded->subject->value, $edit['subject'], 'Subject loaded.');
$this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[' . $langcode . '][0][value]'], 'Comment body loaded.');
$this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[0][value]'], 'Comment body loaded.');
$this->assertEqual($comment_loaded->name->value, $edit['name'], 'Name loaded.');
$this->assertEqual($comment_loaded->created->value, $raw_date, 'Date loaded.');
}
}
......@@ -94,9 +94,8 @@ function setUp() {
* The posted comment or NULL when posted comment was not found.
*/
function postComment($entity, $comment, $subject = '', $contact = NULL) {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array();
$edit['comment_body[' . $langcode . '][0][value]'] = $comment;
$edit['comment_body[0][value]'] = $comment;
$preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL);
$subject_mode = variable_get('comment_subject_field_article', 1);
......
......@@ -253,14 +253,14 @@ function testSiteWideContact() {
$edit = array(
'subject' => $this->randomName(),
'message' => $this->randomName(),
$field_name . '[und][0][value]' => $this->randomName(),
$field_name . '[0][value]' => $this->randomName(),
);
$this->drupalPostForm(NULL, $edit, t('Send message'));
$mails = $this->drupalGetMails();
$mail = array_pop($mails);
$this->assertEqual($mail['subject'], t('[@label] @subject', array('@label' => $label, '@subject' => $edit['subject'])));
$this->assertTrue(strpos($mail['body'], $field_label));
$this->assertTrue(strpos($mail['body'], $edit[$field_name . '[und][0][value]']));
$this->assertTrue(strpos($mail['body'], $edit[$field_name . '[0][value]']));
}
/**
......
......@@ -78,7 +78,7 @@ protected function assertBasicTranslation() {
$edit = array('source_langcode[source]' => $source_langcode);
$path = $langcode . '/' . $base_path . '/translations/add/' . $default_langcode . '/' . $langcode;
$this->drupalPostForm($path, $edit, t('Change'));
$this->assertFieldByXPath("//input[@name=\"{$this->fieldName}[fr][0][value]\"]", $values[$source_langcode][$this->fieldName][0]['value'], 'Source language correctly switched.');
$this->assertFieldByXPath("//input[@name=\"{$this->fieldName}[0][value]\"]", $values[$source_langcode][$this->fieldName][0]['value'], 'Source language correctly switched.');
// Add another translation and mark the other ones as outdated.
$values[$langcode] = $this->getNewEntityValues($langcode);
......@@ -226,7 +226,7 @@ protected function getEditValues($values, $langcode, $new = FALSE) {
$langcode = $new ? Language::LANGCODE_NOT_SPECIFIED : $langcode;
foreach ($values[$langcode] as $property => $value) {
if (is_array($value)) {
$edit["{$property}[$langcode][0][value]"] = $value[0]['value'];
$edit["{$property}[0][value]"] = $value[0]['value'];
unset($edit[$property]);
}
}
......
......@@ -312,7 +312,6 @@ private function doNode($type) {
// Create a node using the form in order to generate an add content event
// (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$title = $edit["title"];
$this->drupalPostForm('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
......@@ -370,20 +369,19 @@ private function doNode($type) {
* Random content needed by various node types.
*/
private function getContent($type) {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
switch ($type) {
case 'forum':
$content = array(
"title" => $this->randomName(8),
"taxonomy_forums[$langcode]" => array(1),
"body[$langcode][0][value]" => $this->randomName(32),
'title' => $this->randomName(8),
'taxonomy_forums' => array(1),
'body[0][value]' => $this->randomName(32),
);
break;
default:
$content = array(
"title" => $this->randomName(8),
"body[$langcode][0][value]" => $this->randomName(32),
'title' => $this->randomName(8),
'body[0][value]' => $this->randomName(32),
);
break;
}
......@@ -400,9 +398,8 @@ private function getContent($type) {
* Random content needed by various node types.
*/
private function getContentUpdate($type) {
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$content = array(
"body[$langcode][0][value]" => $this->randomName(32),
'body[0][value]' => $this->randomName(32),
);
return $content;
}
......
......@@ -133,9 +133,7 @@ protected function buildEntity(array $form, array &$form_state) {
*/
protected function simplify(array &$form, array &$form_state) {
$field_name = $form_state['field_name'];
$langcode = $form_state['langcode'];
$widget_element =& $form[$field_name][$langcode];
$widget_element =& $form[$field_name]['widget'];
// Hide the field label from displaying within the form, because JavaScript
// displays the equivalent label that was provided within an HTML data
......
......@@ -108,9 +108,9 @@ function testUserWithoutPermission() {
$edit['form_id'] = 'edit_field_form';
$edit['form_token'] = 'xIOzMjuc-PULKsRn_KxFn7xzNk5Bx7XKXLfQfw1qOnA';
$edit['form_build_id'] = 'form-kVmovBpyX-SJfTT5kY0pjTV35TV-znor--a64dEnMR8';
$edit['body[und][0][summary]'] = '';
$edit['body[und][0][value]'] = '<p>Malicious content.</p>';
$edit['body[und][0][format]'] = 'filtered_html';
$edit['body[0][summary]'] = '';
$edit['body[0][value]'] = '<p>Malicious content.</p>';
$edit['body[0][format]'] = 'filtered_html';
$edit['op'] = t('Save');
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
......@@ -195,9 +195,9 @@ function testUserWithPermission() {
'form_id' => 'edit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
'body[und][0][summary]' => '',
'body[und][0][value]' => '<p>Fine thanks.</p>',
'body[und][0][format]' => 'filtered_html',
'body[0][summary]' => '',
'body[0][value]' => '<p>Fine thanks.</p>',
'body[0][format]' => 'filtered_html',
'op' => t('Save'),
);
$post += $this->getAjaxPageStatePostData();
......
......@@ -102,7 +102,7 @@ function testLoading() {
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-body-und-0-value"]');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
$this->drupalLogout($this->privileged_user);
......@@ -129,7 +129,7 @@ function testLoading() {
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
$hidden_input = $this->xpath('//input[@type="hidden" and @value="plain_text" and contains(@class, "editor") and @data-editor-for="edit-body-und-0-value"]');
$hidden_input = $this->xpath('//input[@type="hidden" and @value="plain_text" and contains(@class, "editor") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($hidden_input) === 1, 'A single text format hidden input exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
// Create an "article" node that users the full_html text format, then try
......@@ -148,7 +148,7 @@ function testLoading() {
$this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
$this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertFieldByXPath('//textarea[@id="edit-body-und-0-value" and @disabled="disabled"]', t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.');
$this->assertFieldByXPath('//textarea[@id="edit-body-0-value" and @disabled="disabled"]', t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
$hidden_input = $this->xpath('//input[@type="hidden" and contains(@class, "editor")]');
$this->assertTrue(count($hidden_input) === 0, 'A single text format hidden input does not exist on the page.');
......@@ -164,7 +164,7 @@ protected function getThingsToCheck() {
// Editor.module's JS present.
isset($settings['ajaxPageState']['js']['core/modules/editor/js/editor.js']),
// Body field.
$this->xpath('//textarea[@id="edit-body-und-0-value"]'),
$this->xpath('//textarea[@id="edit-body-0-value"]'),
// Format selector.
$this->xpath('//select[contains(@class, "filter-list")]'),
);
......