Commit 537cc876 authored by alexpott's avatar alexpott

Issue #2333731 by Berdir: Fixed WebTestBase::drupalCreateNode() should not hardcode default values.

parent a1f0ff2d
...@@ -88,7 +88,7 @@ public function testUsersWithoutPermission() { ...@@ -88,7 +88,7 @@ public function testUsersWithoutPermission() {
$this->assertRaw('<p>Do you also love Drupal?</p><figure class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>'); $this->assertRaw('<p>Do you also love Drupal?</p><figure class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
// Retrieving the untransformed text should result in an empty 403 response. // Retrieving the untransformed text should result in an empty 403 response.
$response = $this->drupalPost('editor/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', array()); $response = $this->drupalPost('editor/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', array());
$this->assertResponse(403); $this->assertResponse(403);
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed. // @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
// $this->assertIdentical('[]', $response); // $this->assertIdentical('[]', $response);
...@@ -106,7 +106,7 @@ public function testUserWithPermission() { ...@@ -106,7 +106,7 @@ public function testUserWithPermission() {
// Ensure the text is transformed. // Ensure the text is transformed.
$this->assertRaw('<p>Do you also love Drupal?</p><figure class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>'); $this->assertRaw('<p>Do you also love Drupal?</p><figure class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
$response = $this->drupalPost('editor/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', array()); $response = $this->drupalPost('editor/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', array());
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The untransformed text POST request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The untransformed text POST request results in one AJAX command.');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Tests; namespace Drupal\node\Tests;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
/** /**
* Tests node access functionality with multiple languages and two node access * Tests node access functionality with multiple languages and two node access
...@@ -171,18 +172,22 @@ protected function setUp() { ...@@ -171,18 +172,22 @@ protected function setUp() {
$this->nodes['public_no_language_private'] = $this->drupalCreateNode(array( $this->nodes['public_no_language_private'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 1)), 'field_private' => array(array('value' => 1)),
'private' => FALSE, 'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
$this->nodes['public_no_language_public'] = $this->drupalCreateNode(array( $this->nodes['public_no_language_public'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 0)), 'field_private' => array(array('value' => 0)),
'private' => FALSE, 'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
$this->nodes['private_no_language_private'] = $this->drupalCreateNode(array( $this->nodes['private_no_language_private'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 1)), 'field_private' => array(array('value' => 1)),
'private' => TRUE, 'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
$this->nodes['private_no_language_public'] = $this->drupalCreateNode(array( $this->nodes['private_no_language_public'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 1)), 'field_private' => array(array('value' => 1)),
'private' => TRUE, 'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Tests; namespace Drupal\node\Tests;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface;
/** /**
* Tests node_access and db_select() with node_access tag functionality with * Tests node_access and db_select() with node_access tag functionality with
...@@ -134,9 +135,11 @@ protected function setUp() { ...@@ -134,9 +135,11 @@ protected function setUp() {
$this->nodes['no_language_public'] = $this->drupalCreateNode(array( $this->nodes['no_language_public'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 0)), 'field_private' => array(array('value' => 0)),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
$this->nodes['no_language_private'] = $this->drupalCreateNode(array( $this->nodes['no_language_private'] = $this->drupalCreateNode(array(
'field_private' => array(array('value' => 1)), 'field_private' => array(array('value' => 1)),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
} }
......
...@@ -79,7 +79,10 @@ function testNodeAccess() { ...@@ -79,7 +79,10 @@ function testNodeAccess() {
// Creating a public node with no special langcode, like when no language // Creating a public node with no special langcode, like when no language
// module enabled. // module enabled.
$node_public_no_language = $this->drupalCreateNode(array('private' => FALSE)); $node_public_no_language = $this->drupalCreateNode(array(
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$this->assertTrue($node_public_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); $this->assertTrue($node_public_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is granted if requested with no language. // Tests that access is granted if requested with no language.
...@@ -169,7 +172,10 @@ function testNodeAccessPrivate() { ...@@ -169,7 +172,10 @@ function testNodeAccessPrivate() {
// Creating a private node with no special langcode, like when no language // Creating a private node with no special langcode, like when no language
// module enabled. // module enabled.
$node_private_no_language = $this->drupalCreateNode(array('private' => TRUE)); $node_private_no_language = $this->drupalCreateNode(array(
'private' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$this->assertTrue($node_private_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); $this->assertTrue($node_private_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is not granted if requested with no language. // Tests that access is not granted if requested with no language.
...@@ -242,7 +248,10 @@ function testNodeAccessQueryTag() { ...@@ -242,7 +248,10 @@ function testNodeAccessQueryTag() {
// Creating a public node with no special langcode, like when no language // Creating a public node with no special langcode, like when no language
// module enabled. // module enabled.
$node_no_language = $this->drupalCreateNode(array('private' => FALSE)); $node_no_language = $this->drupalCreateNode(array(
'private' => FALSE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$this->assertTrue($node_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); $this->assertTrue($node_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Query the nodes table as the web user with the node access tag and no // Query the nodes table as the web user with the node access tag and no
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\content_translation\Tests\ContentTranslationUITest; use Drupal\content_translation\Tests\ContentTranslationUITest;
use Drupal\Core\Language\LanguageInterface;
/** /**
* Tests the Node Translation UI. * Tests the Node Translation UI.
...@@ -208,7 +209,10 @@ public function testDisabledBundle() { ...@@ -208,7 +209,10 @@ public function testDisabledBundle() {
$this->drupalCreateContentType(array('type' => $disabledBundle, 'name' => $disabledBundle)); $this->drupalCreateContentType(array('type' => $disabledBundle, 'name' => $disabledBundle));
// Create a node for each bundle. // Create a node for each bundle.
$node = $this->drupalCreateNode(array('type' => $this->bundle)); $node = $this->drupalCreateNode(array(
'type' => $this->bundle,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
// Make sure that nothing was inserted into the {content_translation} table. // Make sure that nothing was inserted into the {content_translation} table.
$rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $rows = db_query('SELECT * FROM {content_translation}')->fetchAll();
......
...@@ -27,7 +27,9 @@ class BulkFormTest extends NodeTestBase { ...@@ -27,7 +27,9 @@ class BulkFormTest extends NodeTestBase {
*/ */
public function testBulkForm() { public function testBulkForm() {
$this->drupalLogin($this->drupalCreateUser(array('administer nodes'))); $this->drupalLogin($this->drupalCreateUser(array('administer nodes')));
$node = $this->drupalCreateNode(); $node = $this->drupalCreateNode(array(
'promote' => FALSE,
));
$this->drupalGet('test-node-bulk-form'); $this->drupalGet('test-node-bulk-form');
$elements = $this->xpath('//select[@id="edit-action"]//option'); $elements = $this->xpath('//select[@id="edit-action"]//option');
......
...@@ -134,7 +134,7 @@ protected function setUp() { ...@@ -134,7 +134,7 @@ protected function setUp() {
public function testAutocompleteQuickEdit() { public function testAutocompleteQuickEdit() {
$this->drupalLogin($this->editor_user); $this->drupalLogin($this->editor_user);
$quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full'; $quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/' . $this->node->language()->getId() . '/full';
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
...@@ -164,7 +164,7 @@ public function testAutocompleteQuickEdit() { ...@@ -164,7 +164,7 @@ public function testAutocompleteQuickEdit() {
$this->assertNoLink('new term'); $this->assertNoLink('new term');
// Load the form again, which should now get it back from TempStore. // Load the form again, which should now get it back from TempStore.
$quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full'; $quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/' . $this->node->language()->getId() . '/full';
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
......
...@@ -79,15 +79,15 @@ public function testUserWithoutPermission() { ...@@ -79,15 +79,15 @@ public function testUserWithoutPermission() {
// HTML annotation must always exist (to not break the render cache). // HTML annotation must always exist (to not break the render cache).
$this->assertRaw('data-quickedit-entity-id="node/1"'); $this->assertRaw('data-quickedit-entity-id="node/1"');
$this->assertRaw('data-quickedit-field-id="node/1/body/und/full"'); $this->assertRaw('data-quickedit-field-id="node/1/body/en/full"');
// Retrieving the metadata should result in an empty 403 response. // Retrieving the metadata should result in an empty 403 response.
$post = array('fields[0]' => 'node/1/body/und/full'); $post = array('fields[0]' => 'node/1/body/en/full');
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post); $response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
$this->assertIdentical('{}', $response); $this->assertIdentical('{}', $response);
$this->assertResponse(403); $this->assertResponse(403);
// Quick Edit's JavaScript would never hit these endpoints if the metadata // Quick Edit's JavaScript would SearchRankingTestnever hit these endpoints if the metadata
// was empty as above, but we need to make sure that malicious users aren't // was empty as above, but we need to make sure that malicious users aren't
// able to use any of the other endpoints either. // able to use any of the other endpoints either.
$post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData(); $post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData();
...@@ -96,7 +96,7 @@ public function testUserWithoutPermission() { ...@@ -96,7 +96,7 @@ public function testUserWithoutPermission() {
// $this->assertIdentical('[]', $response); // $this->assertIdentical('[]', $response);
$this->assertResponse(403); $this->assertResponse(403);
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed. // @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
// $this->assertIdentical('[]', $response); // $this->assertIdentical('[]', $response);
$this->assertResponse(403); $this->assertResponse(403);
...@@ -108,7 +108,7 @@ public function testUserWithoutPermission() { ...@@ -108,7 +108,7 @@ public function testUserWithoutPermission() {
$edit['body[0][value]'] = '<p>Malicious content.</p>'; $edit['body[0][value]'] = '<p>Malicious content.</p>';
$edit['body[0][format]'] = 'filtered_html'; $edit['body[0][format]'] = 'filtered_html';
$edit['op'] = t('Save'); $edit['op'] = t('Save');
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $edit); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $edit);
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed. // @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
// $this->assertIdentical('[]', $response); // $this->assertIdentical('[]', $response);
$this->assertResponse(403); $this->assertResponse(403);
...@@ -135,7 +135,7 @@ public function testUserWithPermission() { ...@@ -135,7 +135,7 @@ public function testUserWithPermission() {
// HTML annotation must always exist (to not break the render cache). // HTML annotation must always exist (to not break the render cache).
$this->assertRaw('data-quickedit-entity-id="node/1"'); $this->assertRaw('data-quickedit-entity-id="node/1"');
$this->assertRaw('data-quickedit-field-id="node/1/body/und/full"'); $this->assertRaw('data-quickedit-field-id="node/1/body/en/full"');
// There should be only one revision so far. // There should be only one revision so far.
$node = node_load(1); $node = node_load(1);
...@@ -145,11 +145,11 @@ public function testUserWithPermission() { ...@@ -145,11 +145,11 @@ public function testUserWithPermission() {
// Retrieving the metadata should result in a 200 JSON response. // Retrieving the metadata should result in a 200 JSON response.
$htmlPageDrupalSettings = $this->drupalSettings; $htmlPageDrupalSettings = $this->drupalSettings;
$post = array('fields[0]' => 'node/1/body/und/full'); $post = array('fields[0]' => 'node/1/body/en/full');
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post); $response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
$this->assertResponse(200); $this->assertResponse(200);
$expected = array( $expected = array(
'node/1/body/und/full' => array( 'node/1/body/en/full' => array(
'label' => 'Body', 'label' => 'Body',
'access' => TRUE, 'access' => TRUE,
'editor' => 'form', 'editor' => 'form',
...@@ -177,7 +177,7 @@ public function testUserWithPermission() { ...@@ -177,7 +177,7 @@ public function testUserWithPermission() {
// Retrieving the form for this field should result in a 200 response, // Retrieving the form for this field should result in a 200 response,
// containing only a quickeditFieldForm command. // containing only a quickeditFieldForm command.
$post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
...@@ -205,7 +205,7 @@ public function testUserWithPermission() { ...@@ -205,7 +205,7 @@ public function testUserWithPermission() {
// Submit field form and check response. This should store the updated // Submit field form and check response. This should store the updated
// entity in TempStore on the server. // entity in TempStore on the server.
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
...@@ -247,7 +247,7 @@ public function testUserWithPermission() { ...@@ -247,7 +247,7 @@ public function testUserWithPermission() {
// Retrieve field form. // Retrieve field form.
$post = array('nocssjs' => 'true', 'reset' => 'true'); $post = array('nocssjs' => 'true', 'reset' => 'true');
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
...@@ -264,7 +264,7 @@ public function testUserWithPermission() { ...@@ -264,7 +264,7 @@ public function testUserWithPermission() {
'form_build_id' => $build_id_match[1], 'form_build_id' => $build_id_match[1],
); );
$post += $edit + $this->getAjaxPageStatePostData(); $post += $edit + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed. // @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
// $this->assertIdentical('[]', $response); // $this->assertIdentical('[]', $response);
$this->assertResponse(200); $this->assertResponse(200);
...@@ -299,16 +299,16 @@ public function testTitleBaseField() { ...@@ -299,16 +299,16 @@ public function testTitleBaseField() {
// Ensure that the full page title is actually in-place editable // Ensure that the full page title is actually in-place editable
$node = entity_load('node', 1); $node = entity_load('node', 1);
$elements = $this->xpath('//h1/span[@data-quickedit-field-id="node/1/title/und/full" and normalize-space(text())=:title]', array(':title' => $node->label())); $elements = $this->xpath('//h1/span[@data-quickedit-field-id="node/1/title/en/full" and normalize-space(text())=:title]', array(':title' => $node->label()));
$this->assertTrue(!empty($elements), 'Title with data-quickedit-field-id attribute found.'); $this->assertTrue(!empty($elements), 'Title with data-quickedit-field-id attribute found.');
// Retrieving the metadata should result in a 200 JSON response. // Retrieving the metadata should result in a 200 JSON response.
$htmlPageDrupalSettings = $this->drupalSettings; $htmlPageDrupalSettings = $this->drupalSettings;
$post = array('fields[0]' => 'node/1/title/und/full'); $post = array('fields[0]' => 'node/1/title/en/full');
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post); $response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
$this->assertResponse(200); $this->assertResponse(200);
$expected = array( $expected = array(
'node/1/title/und/full' => array( 'node/1/title/en/full' => array(
'label' => 'Title', 'label' => 'Title',
'access' => TRUE, 'access' => TRUE,
'editor' => 'plain_text', 'editor' => 'plain_text',
...@@ -323,7 +323,7 @@ public function testTitleBaseField() { ...@@ -323,7 +323,7 @@ public function testTitleBaseField() {
// Retrieving the form for this field should result in a 200 response, // Retrieving the form for this field should result in a 200 response,
// containing only a quickeditFieldForm command. // containing only a quickeditFieldForm command.
$post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/title/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
...@@ -350,7 +350,7 @@ public function testTitleBaseField() { ...@@ -350,7 +350,7 @@ public function testTitleBaseField() {
// Submit field form and check response. This should store the // Submit field form and check response. This should store the
// updated entity in TempStore on the server. // updated entity in TempStore on the server.
$response = $this->drupalPost('quickedit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/title/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
...@@ -388,7 +388,7 @@ public function testPseudoFields() { ...@@ -388,7 +388,7 @@ public function testPseudoFields() {
$this->drupalGet('node/1'); $this->drupalGet('node/1');
// Check that the data- attribute is not added. // Check that the data- attribute is not added.
$this->assertNoRaw('data-quickedit-field-id="node/1/quickedit_test_pseudo_field/und/default"'); $this->assertNoRaw('data-quickedit-field-id="node/1/quickedit_test_pseudo_field/en/default"');
} }
/** /**
...@@ -411,7 +411,7 @@ public function testDisplayOptions() { ...@@ -411,7 +411,7 @@ public function testDisplayOptions() {
public function testCustomPipeline() { public function testCustomPipeline() {
\Drupal::moduleHandler()->install(array('quickedit_test')); \Drupal::moduleHandler()->install(array('quickedit_test'));
$custom_render_url = 'quickedit/form/node/1/body/und/quickedit_test-custom-render-data'; $custom_render_url = 'quickedit/form/node/1/body/en/quickedit_test-custom-render-data';
$this->drupalLogin($this->editor_user); $this->drupalLogin($this->editor_user);
// Request editing to render results with the custom render pipeline. // Request editing to render results with the custom render pipeline.
...@@ -460,7 +460,7 @@ public function testConcurrentEdit() { ...@@ -460,7 +460,7 @@ public function testConcurrentEdit() {
$this->drupalLogin($this->editor_user); $this->drupalLogin($this->editor_user);
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData(); $post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
...@@ -487,7 +487,7 @@ public function testConcurrentEdit() { ...@@ -487,7 +487,7 @@ public function testConcurrentEdit() {
// Submit field form and check response. Should throw a validation error // Submit field form and check response. Should throw a validation error
// because the node was changed in the meantime. // because the node was changed in the meantime.
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200); $this->assertResponse(200);
$ajax_commands = Json::decode($response); $ajax_commands = Json::decode($response);
$this->assertIdentical(2, count($ajax_commands), 'The field form HTTP request results in two AJAX commands.'); $this->assertIdentical(2, count($ajax_commands), 'The field form HTTP request results in two AJAX commands.');
......
...@@ -56,6 +56,8 @@ public function testRankings() { ...@@ -56,6 +56,8 @@ public function testRankings() {
)), )),
'title' => 'Drupal rocks', 'title' => 'Drupal rocks',
'body' => array(array('value' => "Drupal's search rocks")), 'body' => array(array('value' => "Drupal's search rocks")),
'sticky' => 0,
'promote' => 0,
); );
foreach (array(0, 1) as $num) { foreach (array(0, 1) as $num) {
if ($num == 1) { if ($num == 1) {
......
...@@ -225,16 +225,8 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { ...@@ -225,16 +225,8 @@ function drupalGetNodeByTitle($title, $reset = FALSE) {
* ); * );
* @endcode * @endcode
* - title: Random string. * - title: Random string.
* - comment: CommentItemInterface::OPEN.
* - promote: NODE_NOT_PROMOTED.
* - log: Empty string.
* - status: NODE_PUBLISHED.
* - sticky: NODE_NOT_STICKY.
* - type: 'page'. * - type: 'page'.
* - langcode: LanguageInterface::LANGCODE_NOT_SPECIFIED. * - uid: The currently logged in user, or anonymous.
* - uid: The currently logged in user, or the user running test.
* - revision: 1. (Backwards-compatible binary flag indicating whether a
* new revision should be created; use 1 to specify a new revision.)
* *
* @return \Drupal\node\NodeInterface * @return \Drupal\node\NodeInterface
* The created node entity. * The created node entity.
...@@ -242,44 +234,15 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { ...@@ -242,44 +234,15 @@ function drupalGetNodeByTitle($title, $reset = FALSE) {
protected function drupalCreateNode(array $settings = array()) { protected function drupalCreateNode(array $settings = array()) {
// Populate defaults array. // Populate defaults array.
$settings += array( $settings += array(
'body' => array(array()), 'body' => array(array(
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
)),
'title' => $this->randomMachineName(8), 'title' => $this->randomMachineName(8),
'promote' => NODE_NOT_PROMOTED,
'revision' => 1,
'log' => '',
'status' => NODE_PUBLISHED,
'sticky' => NODE_NOT_STICKY,
'type' => 'page', 'type' => 'page',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'uid' => \Drupal::currentUser()->id(),
); );
// Use the original node's created time for existing nodes.
if (isset($settings['created']) && !isset($settings['date'])) {
$settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
}
// If the node's user uid is not specified manually, use the currently
// logged in user if available, or else the user running the test.
if (!isset($settings['uid'])) {
if ($this->loggedInUser) {
$settings['uid'] = $this->loggedInUser->id();
}
else {
$user = \Drupal::currentUser() ?: new AnonymousUserSession();
$settings['uid'] = $user->id();
}
}
// Merge body field value and format separately.
$settings['body'][0] += array(
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
);
$node = entity_create('node', $settings); $node = entity_create('node', $settings);
if (!empty($settings['revision'])) {
$node->setNewRevision();
}
$node->save(); $node->save();
<