X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FNodeFormButtonsTest.php;fp=web%2Fcore%2Fmodules%2Fnode%2Ftests%2Fsrc%2FFunctional%2FNodeFormButtonsTest.php;h=0000000000000000000000000000000000000000;hp=546a6334adf022edab4af109ab77553bdea56547;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/node/tests/src/Functional/NodeFormButtonsTest.php b/web/core/modules/node/tests/src/Functional/NodeFormButtonsTest.php deleted file mode 100644 index 546a6334a..000000000 --- a/web/core/modules/node/tests/src/Functional/NodeFormButtonsTest.php +++ /dev/null @@ -1,135 +0,0 @@ -webUser = $this->drupalCreateUser(['create article content', 'edit own article content']); - // Create a user that has access to change the state of the node. - $this->adminUser = $this->drupalCreateUser(['administer nodes', 'bypass node access']); - } - - /** - * Tests that the right buttons are displayed for saving nodes. - */ - public function testNodeFormButtons() { - $node_storage = $this->container->get('entity.manager')->getStorage('node'); - // Log in as administrative user. - $this->drupalLogin($this->adminUser); - - // Verify the buttons on a node add form. - $this->drupalGet('node/add/article'); - $this->assertButtons([t('Save and publish'), t('Save as unpublished')]); - - // Save the node and assert it's published after clicking - // 'Save and publish'. - $edit = ['title[0][value]' => $this->randomString()]; - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); - - // 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 and keep published'), t('Save and unpublish')]); - - // Save the node and verify it's still published after clicking - // 'Save and keep published'. - $this->drupalPostForm(NULL, $edit, t('Save and keep published')); - $node_storage->resetCache([1]); - $node_1 = $node_storage->load(1); - $this->assertTrue($node_1->isPublished(), 'Node is published'); - - // Save the node and verify it's unpublished after clicking - // 'Save and unpublish'. - $this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save and unpublish')); - $node_storage->resetCache([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 and keep unpublished'), t('Save and publish')]); - - // 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 = ['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'); - - // Log in as an administrator and unpublish the node that just - // was created by the normal user. - $this->drupalLogout(); - $this->drupalLogin($this->adminUser); - $this->drupalPostForm('node/' . $node_2->id() . '/edit', [], t('Save and unpublish')); - $node_storage->resetCache([2]); - $node_2 = $node_storage->load(2); - $this->assertFalse($node_2->isPublished(), 'Node is unpublished'); - - // Log in 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', [], t('Save')); - $node_storage->resetCache([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 as unpublished'), t('Save and publish')]); - - // Verify the node is unpublished by default for a normal user. - $this->drupalLogout(); - $this->drupalLogin($this->webUser); - $edit = ['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'); - } - -}