From 1ba3b1fc0d001c08d0aa336f00de2a6f70e5d82e Mon Sep 17 00:00:00 2001 From: timmillwood <timmillwood@227849.no-reply.drupal.org> Date: Thu, 15 Sep 2016 15:10:07 +0100 Subject: [PATCH] Issue #2800433 by timmillwood: Add test for Purge functionality --- tests/src/Functional/PurgeEntityTest.php | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/src/Functional/PurgeEntityTest.php diff --git a/tests/src/Functional/PurgeEntityTest.php b/tests/src/Functional/PurgeEntityTest.php new file mode 100644 index 0000000..88992b9 --- /dev/null +++ b/tests/src/Functional/PurgeEntityTest.php @@ -0,0 +1,102 @@ +<?php + +namespace Drupal\Tests\trash\Functional; + +use Drupal\Tests\BrowserTestBase; + +/** + * Tests purging nodes and blocks from trash. + * + * @group trash + */ +class PurgeEntityTest extends BrowserTestBase { + use TrashTestTrait; + + public static $modules = [ + 'block_content', + 'node', + 'content_moderation', + 'trash' + ]; + + protected $permissions = [ + 'administer moderation states', + 'view any unpublished content', + 'use published_archived transition', + 'use draft_draft transition', + 'use published_draft transition', + 'use published_published transition', + 'use draft_published transition', + 'use archived_published transition', + 'use archived_draft transition', + 'access content overview', + ]; + + public function testPurgeNode() { + $node_type = $this->createNodeType('test'); + $this->permissions = array_merge($this->permissions, + [ + 'administer nodes', + 'administer content types', + 'access content', + 'create test content', + 'edit own test content', + 'delete own test content', + ]); + $editor1 = $this->drupalCreateUser($this->permissions); + $this->drupalLogin($editor1); + + $session = $this->getSession(); + + $this->drupalGet('/admin/structure/types/manage/test/moderation'); + $page = $session->getPage(); + $page->checkField('edit-enable-moderation-state'); + $page->findButton(t('Save'))->click(); + + $this->createContent($node_type, 'Moderated content'); + $this->drupalGet('/admin/content'); + $this->assertTrue($session->getPage()->hasContent("Moderated content")); + $session->getPage()->clickLink('Delete'); + $this->assertTrue($session->getPage()->hasContent("The Content Moderated content has been moved to the trash.")); + + $this->drupalGet('/admin/trash'); + $this->assertTrue($session->getPage()->hasContent('Moderated content')); + $session->getPage()->clickLink('Purge'); + $session->getPage()->findButton(t('Purge'))->click(); + $this->drupalGet('/admin/content'); + $this->assertFalse($session->getPage()->hasContent("Moderated content")); + + } + + public function testPurgeBlock() { + $block_type = $this->createBlockContentType('test'); + + $this->permissions = array_merge($this->permissions, + [ + 'administer blocks', + ]); + $editor1 = $this->drupalCreateUser($this->permissions); + $this->drupalLogin($editor1); + + $session = $this->getSession(); + + $this->drupalGet('admin/structure/block/block-content/manage/' . $block_type->id() . '/moderation'); + $page = $session->getPage(); + $page->checkField('edit-enable-moderation-state'); + $page->findButton(t('Save'))->click(); + + $this->createBlock($block_type, 'Moderated block'); + $this->drupalGet('/admin/structure/block/block-content'); + $this->assertTrue($session->getPage()->hasContent('Moderated block')); + $session->getPage()->clickLink('Delete'); + $this->assertTrue($session->getPage()->hasContent("The Custom block Moderated block has been moved to the trash.")); + + $this->drupalGet('/admin/trash'); + $this->assertTrue($session->getPage()->hasContent("Moderated block")); + $session->getPage()->clickLink('Purge'); + $session->getPage()->findButton(t('Purge'))->click(); + $this->drupalGet('/admin/structure/block/block-content'); + $this->assertFalse($session->getPage()->hasContent('Moderated block')); + } + +} -- GitLab