diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php index ff25d40842e80473bee8e3cea94c4b25811a162d..13b882a9c0657599cc0d26de4ded81806e7a1f2e 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php @@ -88,7 +88,7 @@ public function testUsersWithoutPermission() { $this->assertRaw('

Do you also love Drupal?

Druplicon
'); // 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); // @todo Uncomment the below once https://drupal.org/node/2063303 is fixed. // $this->assertIdentical('[]', $response); @@ -106,7 +106,7 @@ public function testUserWithPermission() { // Ensure the text is transformed. $this->assertRaw('

Do you also love Drupal?

Druplicon
'); - $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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The untransformed text POST request results in one AJAX command.'); diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php index ce664abf8c22f462084d2944443830a6c2c00fed..5252a355356ff98e20d4e11fdb3b77ca26674ad1 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests node access functionality with multiple languages and two node access @@ -171,18 +172,22 @@ protected function setUp() { $this->nodes['public_no_language_private'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 1)), 'private' => FALSE, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->nodes['public_no_language_public'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 0)), 'private' => FALSE, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->nodes['private_no_language_private'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 1)), 'private' => TRUE, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->nodes['private_no_language_public'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 1)), 'private' => TRUE, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); } diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php index ed91a570700b92685954ca3fa81aeff4eed161ec..77ba270f410e36941862fdda71e675107d360255 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests node_access and db_select() with node_access tag functionality with @@ -134,9 +135,11 @@ protected function setUp() { $this->nodes['no_language_public'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 0)), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->nodes['no_language_private'] = $this->drupalCreateNode(array( 'field_private' => array(array('value' => 1)), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); } diff --git a/core/modules/node/src/Tests/NodeAccessLanguageTest.php b/core/modules/node/src/Tests/NodeAccessLanguageTest.php index b269582a5e4229d89ac6cccd761625e72e662909..6aeaf7504fec5dd9e3a2639cf3c440c0c5a04776 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php @@ -79,7 +79,10 @@ function testNodeAccess() { // Creating a public node with no special langcode, like when no language // 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.'); // Tests that access is granted if requested with no language. @@ -169,7 +172,10 @@ function testNodeAccessPrivate() { // Creating a private node with no special langcode, like when no language // 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.'); // Tests that access is not granted if requested with no language. @@ -242,7 +248,10 @@ function testNodeAccessQueryTag() { // Creating a public node with no special langcode, like when no language // 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.'); // Query the nodes table as the web user with the node access tag and no diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index 9968cff91802c036e02fc68f7f9585d0915d84d1..7d3c651277d0f74cc835676d8adeb7e4a8b0aa36 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\Tests\ContentTranslationUITest; +use Drupal\Core\Language\LanguageInterface; /** * Tests the Node Translation UI. @@ -208,7 +209,10 @@ public function testDisabledBundle() { $this->drupalCreateContentType(array('type' => $disabledBundle, 'name' => $disabledBundle)); // 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. $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); diff --git a/core/modules/node/src/Tests/Views/BulkFormTest.php b/core/modules/node/src/Tests/Views/BulkFormTest.php index 53600e9ed8d1c0661eb8f881e40a3f79d207051e..c2eba803258a6313720a89e6ac6933fceab5caca 100644 --- a/core/modules/node/src/Tests/Views/BulkFormTest.php +++ b/core/modules/node/src/Tests/Views/BulkFormTest.php @@ -27,7 +27,9 @@ class BulkFormTest extends NodeTestBase { */ public function testBulkForm() { $this->drupalLogin($this->drupalCreateUser(array('administer nodes'))); - $node = $this->drupalCreateNode(); + $node = $this->drupalCreateNode(array( + 'promote' => FALSE, + )); $this->drupalGet('test-node-bulk-form'); $elements = $this->xpath('//select[@id="edit-action"]//option'); diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php index 7e91724fcd6f2183508c83038bf8bdcf9a9043f7..d7752a54f647569546d8184cb8d2e79fac7b4181 100644 --- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php @@ -134,7 +134,7 @@ protected function setUp() { public function testAutocompleteQuickEdit() { $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(); $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post); $ajax_commands = Json::decode($response); @@ -164,7 +164,7 @@ public function testAutocompleteQuickEdit() { $this->assertNoLink('new term'); // 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(); $response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post); $ajax_commands = Json::decode($response); diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php index 6a084f620e6d07c3f74970addd824714d047b414..f795ad381945790a2ad452b505a0fb8538b1795f 100644 --- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php @@ -79,15 +79,15 @@ public function testUserWithoutPermission() { // HTML annotation must always exist (to not break the render cache). $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. - $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); $this->assertIdentical('{}', $response); $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 // able to use any of the other endpoints either. $post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData(); @@ -96,7 +96,7 @@ public function testUserWithoutPermission() { // $this->assertIdentical('[]', $response); $this->assertResponse(403); $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. // $this->assertIdentical('[]', $response); $this->assertResponse(403); @@ -108,7 +108,7 @@ public function testUserWithoutPermission() { $edit['body[0][value]'] = '

Malicious content.

'; $edit['body[0][format]'] = 'filtered_html'; $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. // $this->assertIdentical('[]', $response); $this->assertResponse(403); @@ -135,7 +135,7 @@ public function testUserWithPermission() { // HTML annotation must always exist (to not break the render cache). $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. $node = node_load(1); @@ -145,11 +145,11 @@ public function testUserWithPermission() { // Retrieving the metadata should result in a 200 JSON response. $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); $this->assertResponse(200); $expected = array( - 'node/1/body/und/full' => array( + 'node/1/body/en/full' => array( 'label' => 'Body', 'access' => TRUE, 'editor' => 'form', @@ -177,7 +177,7 @@ public function testUserWithPermission() { // Retrieving the form for this field should result in a 200 response, // containing only a quickeditFieldForm command. $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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -205,7 +205,7 @@ public function testUserWithPermission() { // Submit field form and check response. This should store the updated // 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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -247,7 +247,7 @@ public function testUserWithPermission() { // Retrieve field form. $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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -264,7 +264,7 @@ public function testUserWithPermission() { 'form_build_id' => $build_id_match[1], ); $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. // $this->assertIdentical('[]', $response); $this->assertResponse(200); @@ -299,16 +299,16 @@ public function testTitleBaseField() { // Ensure that the full page title is actually in-place editable $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.'); // Retrieving the metadata should result in a 200 JSON response. $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); $this->assertResponse(200); $expected = array( - 'node/1/title/und/full' => array( + 'node/1/title/en/full' => array( 'label' => 'Title', 'access' => TRUE, 'editor' => 'plain_text', @@ -323,7 +323,7 @@ public function testTitleBaseField() { // Retrieving the form for this field should result in a 200 response, // containing only a quickeditFieldForm command. $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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -350,7 +350,7 @@ public function testTitleBaseField() { // Submit field form and check response. This should store the // 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); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -388,7 +388,7 @@ public function testPseudoFields() { $this->drupalGet('node/1'); // 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() { public function testCustomPipeline() { \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); // Request editing to render results with the custom render pipeline. @@ -460,7 +460,7 @@ public function testConcurrentEdit() { $this->drupalLogin($this->editor_user); $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); $ajax_commands = Json::decode($response); @@ -487,7 +487,7 @@ public function testConcurrentEdit() { // Submit field form and check response. Should throw a validation error // 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); $ajax_commands = Json::decode($response); $this->assertIdentical(2, count($ajax_commands), 'The field form HTTP request results in two AJAX commands.'); diff --git a/core/modules/search/src/Tests/SearchRankingTest.php b/core/modules/search/src/Tests/SearchRankingTest.php index b434bc952c84d145f19575c3460c9bec6cfc8a88..af44264d6c6bb2646e5dff6d8a678e8628fbd1fa 100644 --- a/core/modules/search/src/Tests/SearchRankingTest.php +++ b/core/modules/search/src/Tests/SearchRankingTest.php @@ -56,6 +56,8 @@ public function testRankings() { )), 'title' => 'Drupal rocks', 'body' => array(array('value' => "Drupal's search rocks")), + 'sticky' => 0, + 'promote' => 0, ); foreach (array(0, 1) as $num) { if ($num == 1) { diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index e7c1875eb09f7a3f6db3436c5908d57aebea8d1d..8ff3575c63d54647596ef4c866da00ba354f38af 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -225,16 +225,8 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * ); * @endcode * - title: Random string. - * - comment: CommentItemInterface::OPEN. - * - promote: NODE_NOT_PROMOTED. - * - log: Empty string. - * - status: NODE_PUBLISHED. - * - sticky: NODE_NOT_STICKY. * - type: 'page'. - * - langcode: LanguageInterface::LANGCODE_NOT_SPECIFIED. - * - 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.) + * - uid: The currently logged in user, or anonymous. * * @return \Drupal\node\NodeInterface * The created node entity. @@ -242,44 +234,15 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { protected function drupalCreateNode(array $settings = array()) { // Populate defaults array. $settings += array( - 'body' => array(array()), + 'body' => array(array( + 'value' => $this->randomMachineName(32), + 'format' => filter_default_format(), + )), 'title' => $this->randomMachineName(8), - 'promote' => NODE_NOT_PROMOTED, - 'revision' => 1, - 'log' => '', - 'status' => NODE_PUBLISHED, - 'sticky' => NODE_NOT_STICKY, '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); - if (!empty($settings['revision'])) { - $node->setNewRevision(); - } $node->save(); return $node;