diff -u b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php --- b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php @@ -64,8 +64,7 @@ $edit = [ 'title[0][value]' => $this->randomString(), - 'entity_reference_test' => $referenced_node->id(), - 'status[value]' => TRUE, + 'entity_reference_test' => $referenced_node->id() ]; $this->drupalPostForm(NULL, $edit, 'Save'); $this->assertEscaped($referenced_node->getTitle()); diff -u b/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php --- b/core/modules/file/src/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php @@ -73,9 +73,7 @@ $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); // Turn the "display" option off and check that the file is no longer displayed. - $edit = array( - $field_name . '[0][display]' => FALSE, - ); + $edit = array($field_name . '[0][display]' => FALSE); $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.'); @@ -165,7 +163,6 @@ $edit = array( 'title[0][value]' => $title, 'files[field_' . $field_name . '_0]' => drupal_realpath($file->uri), - 'status[value]' => TRUE, ); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); diff -u b/core/modules/file/src/Tests/FileFieldRevisionTest.php b/core/modules/file/src/Tests/FileFieldRevisionTest.php --- b/core/modules/file/src/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/src/Tests/FileFieldRevisionTest.php @@ -68,10 +68,7 @@ // Save a new version of the node without any changes. // Check that the file is still the same as the previous revision. - $edit = array( - 'revision' => TRUE, - ); - $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); + $this->drupalPostForm('node/' . $nid . '/edit', array('revision' => '1'), t('Save')); $node_storage->resetCache(array($nid)); $node = $node_storage->load($nid); $node_file_r3 = File::load($node->{$field_name}->target_id); diff -u b/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php --- b/core/modules/file/src/Tests/FileFieldValidateTest.php +++ b/core/modules/file/src/Tests/FileFieldValidateTest.php @@ -32,10 +32,8 @@ $test_file = $this->getTestFile('text'); // Try to post a new node without uploading a file. - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required file field was empty.'); @@ -55,10 +53,8 @@ $this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1')); // Try to post a new node without uploading a file in the multivalue field. - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required multiple value file field was empty.'); diff -u b/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php --- b/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -210,11 +210,7 @@ $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); // Save the node and ensure it does not have any files. - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, array('title[0][value]' => $this->randomMachineName()), t('Save')); $matches = array(); preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; @@ -336,7 +332,6 @@ // Create node. $edit = array( 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, ); $this->drupalPostForm('node/add/article', $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); @@ -372,9 +367,7 @@ // Unpublishes node. $this->drupalLogin($this->adminUser); - $edit = array( - 'status[value]' => FALSE, - ); + $edit = array('status[value]' => FALSE); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Ensures normal user can no longer download the file. diff -u b/core/modules/file/src/Tests/FilePrivateTest.php b/core/modules/file/src/Tests/FilePrivateTest.php --- b/core/modules/file/src/Tests/FilePrivateTest.php +++ b/core/modules/file/src/Tests/FilePrivateTest.php @@ -75,15 +75,11 @@ $this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.'); // Attempt to reuse the file when editing a node. - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $edit = array( - $field_name . '[0][fids]' => $node_file->id(), - ); + $edit[$field_name . '[0][fids]'] = $node_file->id(); $this->drupalPostForm('node/' . $new_node->id() .'/edit', $edit, t('Save')); // Make sure the form submit failed - we stayed on the edit form. $this->assertUrl('node/' . $new_node->id() .'/edit'); @@ -92,11 +88,9 @@ $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id()))); // Attempt to reuse the existing file when creating a new node, and confirm // that access is still denied. - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - $field_name . '[0][fids]' => $node_file->id(), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(); + $edit[$field_name . '[0][fids]'] = $node_file->id(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertTrue(empty($new_node), 'Node was not created.'); diff -u b/core/modules/filter/src/Tests/FilterHooksTest.php b/core/modules/filter/src/Tests/FilterHooksTest.php --- b/core/modules/filter/src/Tests/FilterHooksTest.php +++ b/core/modules/filter/src/Tests/FilterHooksTest.php @@ -61,12 +61,10 @@ // Use the format created. $title = $this->randomMachineName(8); - $edit = array( - 'title[0][value]' => $title, - 'body[0][value]' => $this->randomMachineName(32), - 'body[0][format]' => $format_id, - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $title; + $edit['body[0][value]'] = $this->randomMachineName(32); + $edit['body[0][format]'] = $format_id; $this->drupalPostForm("node/add/{$type->id()}", $edit, t('Save')); $this->assertText(t('@type @title has been created.', array('@type' => $type_name, '@title' => $title))); diff -u b/core/modules/forum/src/Tests/ForumBlockTest.php b/core/modules/forum/src/Tests/ForumBlockTest.php --- b/core/modules/forum/src/Tests/ForumBlockTest.php +++ b/core/modules/forum/src/Tests/ForumBlockTest.php @@ -171,7 +171,6 @@ // adding the index. 'created[0][value][date]' => $date->format('Y-m-d'), 'created[0][value][time]' => $date->format('H:i:s'), - 'status[value]' => TRUE, ); // Create the forum topic, preselecting the forum ID via a URL parameter. diff -u b/core/modules/forum/src/Tests/ForumIndexTest.php b/core/modules/forum/src/Tests/ForumIndexTest.php --- b/core/modules/forum/src/Tests/ForumIndexTest.php +++ b/core/modules/forum/src/Tests/ForumIndexTest.php @@ -43,7 +43,6 @@ $edit = array( 'title[0][value]' => $title, 'body[0][value]' => $this->randomMachineName(200), - 'status[value]' => TRUE, ); // Create the forum topic, preselecting the forum ID via a URL parameter. @@ -77,9 +76,7 @@ // Unpublish the node. - $edit = array( - 'status[value]' => FALSE, - ); + $edit = array('status[value]' => FALSE); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->id()); $this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.'); diff -u b/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php --- b/core/modules/image/src/Tests/ImageFieldTestBase.php +++ b/core/modules/image/src/Tests/ImageFieldTestBase.php @@ -136,16 +136,11 @@ $edit = array( 'title[0][value]' => $this->randomMachineName(), 'files[' . $field_name . '_0]' => drupal_realpath($image->uri), - 'status[value]' => TRUE, ); $this->drupalPostForm('node/add/' . $type, $edit, t('Save')); if ($alt) { // Add alt text. - $edit = array( - $field_name . '[0][alt]' => $alt, - 'status[value]' => TRUE, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save')); } // Retrieve ID of the newly created node from the current URL. diff -u b/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/src/Tests/ImageFieldValidateTest.php --- b/core/modules/image/src/Tests/ImageFieldValidateTest.php +++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php @@ -87,7 +87,6 @@ $edit = array( 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, ); $this->drupalPostForm('node/add/article', $edit, t('Save')); @@ -101,7 +100,6 @@ $edit = array( 'title[0][value]' => $this->randomMachineName(), - 'status[value]' => TRUE, ); $this->drupalPostForm('node/add/article', $edit, t('Save')); diff -u b/core/modules/node/src/Tests/NodeEditFormTest.php b/core/modules/node/src/Tests/NodeEditFormTest.php --- b/core/modules/node/src/Tests/NodeEditFormTest.php +++ b/core/modules/node/src/Tests/NodeEditFormTest.php @@ -100,11 +100,10 @@ $this->drupalLogin($second_web_user); // Edit the same node, creating a new revision. $this->drupalGet("node/" . $node->id() . "/edit"); - $edit = array( - 'title[0][value]' => $this->randomMachineName(8), - $body_key => $this->randomMachineName(16), - 'revision' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(8); + $edit[$body_key] = $this->randomMachineName(16); + $edit['revision'] = TRUE; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the node revision has been created. @@ -118,6 +117,15 @@ $first_node_version = node_revision_load($node->getRevisionId()); $second_node_version = node_revision_load($revised_node->getRevisionId()); $this->assertNotIdentical($first_node_version->getRevisionAuthor()->id(), $second_node_version->getRevisionAuthor()->id(), 'Each revision has a distinct user.'); + + // Edit the same node, save it and verify it's unpublished after unchecking + // the 'Published' boolean_checkbox and clicking 'Save'. + $this->drupalGet("node/" . $node->id() . "/edit"); + $edit = array('status[value]' => FALSE); + $this->drupalPostForm(NULL, $edit, t('Save')); + $this->nodeStorage->resetCache(array($node->id())); + $node = $this->nodeStorage->load($node->id()); + $this->assertFalse($node->isPublished(), 'Node is unpublished'); } /** @@ -128,11 +136,9 @@ // Create node to edit. $body_key = 'body[0][value]'; - $edit = array( - 'title[0][value]' => $this->randomMachineName(8), - $body_key => $this->randomMachineName(16), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(8); + $edit[$body_key] = $this->randomMachineName(16); $this->drupalPostForm('node/add/page', $edit, t('Save')); // Check that the node was authored by the currently logged in user. @@ -198,9 +204,7 @@ // Change the authored by field to an empty string, which should assign // authorship to the anonymous user (uid 0). - $edit = array( - $form_element_name => '', - ); + $edit[$form_element_name] = ''; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); @@ -212,9 +216,7 @@ // Change the authored by field to another user's name (that is not // logged in). - $edit = array( - $form_element_name => $this->webUser->getUsername(), - ); + $edit[$form_element_name] = $this->webUser->getUsername(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); diff -u b/core/modules/node/src/Tests/NodeFormButtonsTest.php /dev/null --- b/core/modules/node/src/Tests/NodeFormButtonsTest.php +++ /dev/null @@ -1,148 +0,0 @@ -webUser = $this->drupalCreateUser(array('create article content', 'edit own article content')); - // Create a user that has access to change the state of the node. - $this->adminUser = $this->drupalCreateUser(array('administer nodes', 'bypass node access')); - } - - /** - * Tests that the right buttons are displayed for saving nodes. - */ - function testNodeFormButtons() { - $node_storage = $this->container->get('entity.manager')->getStorage('node'); - // Login as administrative user. - $this->drupalLogin($this->adminUser); - - // Verify the buttons on a node add form. - $this->drupalGet('node/add/article'); - $this->assertButtons(t('Save'), FALSE); - - // Save the node and assert it's published after checking the 'Published' - // boolean_checkbox and clicking 'Save'. - $edit = array( - 'title[0][value]' => $this->randomString(), - 'status[value]' => TRUE, - ); - $this->drupalPostForm('node/add/article', $edit, t('Save')); - - // Get the node. - $node_1 = $node_storage->load(1); - $this->assertTrue($node_1->isPublished(), 'Node is published'); - - // Verify the buttons on a node edit form. - $this->drupalGet('node/' . $node_1->id() . '/edit'); - $this->assertButtons(t('Save'), FALSE); - - // Save the node and verify it's still published after clicking - // 'Save'. - $this->drupalPostForm(NULL, $edit, t('Save')); - $node_storage->resetCache(array(1)); - $node_1 = $node_storage->load(1); - $this->assertTrue($node_1->isPublished(), 'Node is published'); - - // Save the node and verify it's unpublished after unchecking the 'Published' - // boolean_checkbox and clicking 'Save'. - $edit = array( - 'status[value]' => FALSE, - ); - $this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save')); - $node_storage->resetCache(array(1)); - $node_1 = $node_storage->load(1); - $this->assertFalse($node_1->isPublished(), 'Node is unpublished'); - - // Verify the buttons on an unpublished node edit screen. - $this->drupalGet('node/' . $node_1->id() . '/edit'); - $this->assertButtons(t('Save'), FALSE); - - // Create a node as a normal user. - $this->drupalLogout(); - $this->drupalLogin($this->webUser); - - // Verify the buttons for a normal user. - $this->drupalGet('node/add/article'); - $this->assertButtons(t('Save'), FALSE); - - // Create the node. - $edit = array('title[0][value]' => $this->randomString()); - $this->drupalPostForm('node/add/article', $edit, t('Save')); - $node_2 = $node_storage->load(2); - $this->assertTrue($node_2->isPublished(), 'Node is published'); - - // Login as an administrator and unpublish the node that just - // was created by the normal user. - $this->drupalLogout(); - $this->drupalLogin($this->adminUser); - $edit = array( - 'status[value]' => FALSE, - ); - $this->drupalPostForm('node/' . $node_2->id() . '/edit', $edit, t('Save')); - $node_storage->resetCache(array(2)); - $node_2 = $node_storage->load(2); - $this->assertFalse($node_2->isPublished(), 'Node is unpublished'); - - // Login again as the normal user, save the node and verify - // it's still unpublished. - $this->drupalLogout(); - $this->drupalLogin($this->webUser); - $this->drupalPostForm('node/' . $node_2->id() . '/edit', array(), t('Save')); - $node_storage->resetCache(array(2)); - $node_2 = $node_storage->load(2); - $this->assertFalse($node_2->isPublished(), 'Node is still unpublished'); - $this->drupalLogout(); - - // Set article content type default to unpublished. This will change the - // the initial order of buttons and/or status of the node when creating - // a node. - $fields = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); - $fields['status']->getConfig('article') - ->setDefaultValue(FALSE) - ->save(); - - // Verify the buttons on a node add form for an administrator. - $this->drupalLogin($this->adminUser); - $this->drupalGet('node/add/article'); - $this->assertButtons(t('Save'), FALSE); - - // Verify the node is unpublished by default for a normal user. - $this->drupalLogout(); - $this->drupalLogin($this->webUser); - $edit = array('title[0][value]' => $this->randomString()); - $this->drupalPostForm('node/add/article', $edit, t('Save')); - $node_3 = $node_storage->load(3); - $this->assertFalse($node_3->isPublished(), 'Node is unpublished'); - } -} diff -u b/core/modules/node/src/Tests/NodeRevisionsUiTest.php b/core/modules/node/src/Tests/NodeRevisionsUiTest.php --- b/core/modules/node/src/Tests/NodeRevisionsUiTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsUiTest.php @@ -59,9 +59,7 @@ $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); // Uncheck the create new revision checkbox and save the node. - $edit = array( - 'revision' => FALSE, - ); + $edit = array('revision' => FALSE); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Load the node again and check the revision is the same as before. diff -u b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php --- b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php @@ -50,10 +50,7 @@ // Link the node to itself to test that it's only indexed once. The content // also needs the word "pizza" so we can use it as the search keyword. $body_key = 'body[0][value]'; - $edit = array( - $body_key => \Drupal::l($node->label(), $node->urlInfo()) . ' pizza sandwich', - 'status[value]' => TRUE, - ); + $edit[$body_key] = \Drupal::l($node->label(), $node->urlInfo()) . ' pizza sandwich'; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); diff -u b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php --- b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php @@ -122,7 +122,7 @@ $this->assertText('Test Article - New title'); $this->assertText('Test 1'); $this->assertRaw('0.01'); - $this->drupalPostForm('node/8/edit', [], 'Save (this translation)'); + $this->drupalPostForm('node/8/edit', NULL, 'Save (this translation)'); $this->assertResponse(200); $this->drupalGet('node/8/edit', ['language' => $spanish]); $this->assertText('Test title Spanish'); diff -u b/core/modules/taxonomy/src/Tests/LegacyTest.php b/core/modules/taxonomy/src/Tests/LegacyTest.php --- b/core/modules/taxonomy/src/Tests/LegacyTest.php +++ b/core/modules/taxonomy/src/Tests/LegacyTest.php @@ -58,14 +58,12 @@ function testTaxonomyLegacyNode() { // Posts an article with a taxonomy term and a date prior to 1970. $date = new DrupalDateTime('1969-01-01 00:00:00'); - $edit = array( - 'title[0][value]' => $this->randomMachineName(), - 'created[0][value][date]' => $date->format('Y-m-d'), - 'created[0][value][time]' => $date->format('H:i:s'), - 'body[0][value]' => $this->randomMachineName(), - 'field_tags[target_id]' => $this->randomMachineName(), - 'status[value]' => TRUE, - ); + $edit = array(); + $edit['title[0][value]'] = $this->randomMachineName(); + $edit['created[0][value][date]'] = $date->format('Y-m-d'); + $edit['created[0][value][time]'] = $date->format('H:i:s'); + $edit['body[0][value]'] = $this->randomMachineName(); + $edit['field_tags[target_id]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/article', $edit, t('Save')); // Checks that the node has been saved. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);