diff --git a/src/Tests/ParagraphsAccessTest.php b/src/Tests/ParagraphsAccessTest.php index a71bd96..c74cbdf 100644 --- a/src/Tests/ParagraphsAccessTest.php +++ b/src/Tests/ParagraphsAccessTest.php @@ -13,7 +13,7 @@ use Drupal\user\Entity\Role; * * @group paragraphs */ -class ParagraphsAccessTest extends WebTestBase { +class ParagraphsAccessTest extends ParagraphsTestBase { use FieldUiTestTrait; @@ -23,12 +23,7 @@ class ParagraphsAccessTest extends WebTestBase { * @var array */ public static $modules = array( - 'node', - 'paragraphs', - 'field', 'image', - 'field_ui', - 'block', 'paragraphs_demo', ); @@ -37,31 +32,20 @@ class ParagraphsAccessTest extends WebTestBase { */ protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('page_title_block'); } /** * Tests the paragraph translation. */ public function testParagraphAccessCheck() { - $admin_user = $this->drupalCreateUser(array( + $admin_user = [ 'administer site configuration', - 'administer nodes', - 'administer content types', - 'administer node fields', 'administer node display', - 'administer paragraphs types', - 'administer paragraph fields', 'administer paragraph display', - 'administer paragraph form display', - 'administer node form display', 'create paragraphed_content_demo content', 'edit any paragraphed_content_demo content', - )); - $this->drupalLogin($admin_user); - - $this->drupalLogin($admin_user); + ]; + $this->loginAsAdmin($admin_user); // Remove the "access content" for anonymous users. That results in // anonymous users not being able to "view" the host entity. @@ -138,7 +122,7 @@ class ParagraphsAccessTest extends WebTestBase { $this->assertResponse(403, 'Image could not be downloaded'); // Login as admin with no delete permissions. - $this->drupalLogin($admin_user); + $this->loginAsAdmin($admin_user); // Create a new demo node. $this->drupalGet('node/add/paragraphed_content_demo'); $this->drupalPostForm(NULL, NULL, t('Add Text')); diff --git a/src/Tests/ParagraphsAdministrationTest.php b/src/Tests/ParagraphsAdministrationTest.php index cdc5db0..0976b96 100644 --- a/src/Tests/ParagraphsAdministrationTest.php +++ b/src/Tests/ParagraphsAdministrationTest.php @@ -11,7 +11,7 @@ use Drupal\simpletest\WebTestBase; * * @group paragraphs */ -class ParagraphsAdministrationTest extends WebTestBase { +class ParagraphsAdministrationTest extends ParagraphsTestBase { use FieldUiTestTrait; @@ -21,12 +21,7 @@ class ParagraphsAdministrationTest extends WebTestBase { * @var array */ public static $modules = array( - 'node', - 'paragraphs', - 'field', 'image', - 'field_ui', - 'block', 'file', 'views' ); @@ -39,28 +34,16 @@ class ParagraphsAdministrationTest extends WebTestBase { // Create paragraphs and article content types. $this->drupalCreateContentType(array('type' => 'paragraphs', 'name' => 'Paragraphs')); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - // Place the breadcrumb, tested in fieldUIAddNewField(). - $this->drupalPlaceBlock('system_breadcrumb_block'); - $this->drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('local_actions_block'); - $this->drupalPlaceBlock('page_title_block'); } /** * Tests the revision of paragraphs. */ public function testParagraphsRevisions() { - $admin_user = $this->drupalCreateUser(array( - 'administer nodes', + $this->loginAsAdmin([ 'create paragraphs content', - 'administer content types', - 'administer node fields', 'administer node display', - 'administer paragraphs types', - 'administer paragraph fields', - 'administer node form display', 'edit any paragraphs content', - )); - $this->drupalLogin($admin_user); + ]); $this->drupalGet('admin/structure/paragraphs_type'); $this->clickLink(t('Add paragraphs type')); @@ -152,24 +135,16 @@ class ParagraphsAdministrationTest extends WebTestBase { * Tests the paragraph creation. */ public function testParagraphsCreation() { - $admin_user = $this->drupalCreateUser(array( + $this->loginAsAdmin([ 'administer site configuration', - 'administer nodes', 'create article content', 'create paragraphs content', - 'administer content types', - 'administer node fields', 'administer node display', - 'administer paragraphs types', - 'administer paragraph fields', 'administer paragraph display', - 'administer paragraph form display', - 'administer node form display', 'edit any article content', 'delete any article content', 'access files overview', - )); - $this->drupalLogin($admin_user); + ]); // Assert suggested 'Add a paragraph type' link when there is no type yet. $this->drupalGet('admin/structure/paragraphs_type'); diff --git a/src/Tests/ParagraphsEditModesTest.php b/src/Tests/ParagraphsEditModesTest.php index e81daa7..1cdce0e 100644 --- a/src/Tests/ParagraphsEditModesTest.php +++ b/src/Tests/ParagraphsEditModesTest.php @@ -19,11 +19,6 @@ class ParagraphsEditModesTest extends ParagraphsTestBase { * @var array */ public static $modules = [ - 'node', - 'paragraphs', - 'field', - 'field_ui', - 'block', 'image', ]; diff --git a/src/Tests/ParagraphsFieldGroupTest.php b/src/Tests/ParagraphsFieldGroupTest.php index 255170d..2ce941a 100644 --- a/src/Tests/ParagraphsFieldGroupTest.php +++ b/src/Tests/ParagraphsFieldGroupTest.php @@ -16,11 +16,7 @@ class ParagraphsFieldGroupTest extends ParagraphsTestBase { * @var array */ public static $modules = [ - 'node', - 'paragraphs', - 'field', 'field_group', - 'field_ui', ]; /** diff --git a/src/Tests/ParagraphsPreviewTest.php b/src/Tests/ParagraphsPreviewTest.php index f88d200..8e78857 100644 --- a/src/Tests/ParagraphsPreviewTest.php +++ b/src/Tests/ParagraphsPreviewTest.php @@ -11,7 +11,7 @@ use Drupal\simpletest\WebTestBase; * * @group paragraphs */ -class ParagraphsPreviewTest extends WebTestBase { +class ParagraphsPreviewTest extends ParagraphsTestBase { use FieldUiTestTrait; @@ -21,12 +21,7 @@ class ParagraphsPreviewTest extends WebTestBase { * @var array */ public static $modules = array( - 'node', - 'paragraphs', - 'field', 'image', - 'field_ui', - 'block', ); /** @@ -36,29 +31,18 @@ class ParagraphsPreviewTest extends WebTestBase { parent::setUp(); // Create paragraphs and article content types. $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - // Place the breadcrumb, tested in fieldUIAddNewField(). - $this->drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('local_actions_block'); - $this->drupalPlaceBlock('system_breadcrumb_block'); } /** * Tests the revision of paragraphs. */ public function testParagraphsPreview() { - $admin_user = $this->drupalCreateUser(array( - 'administer nodes', - 'administer content types', - 'administer node fields', + $this->loginAsAdmin([ 'administer node display', - 'administer paragraphs types', - 'administer paragraph fields', - 'administer node form display', 'create article content', 'edit any article content', 'delete any article content', - )); - $this->drupalLogin($admin_user); + ]); $this->drupalGet('admin/structure/paragraphs_type'); $this->clickLink(t('Add paragraphs type')); diff --git a/src/Tests/ParagraphsTranslationTest.php b/src/Tests/ParagraphsTranslationTest.php index 6a5f0fb..3291d00 100644 --- a/src/Tests/ParagraphsTranslationTest.php +++ b/src/Tests/ParagraphsTranslationTest.php @@ -14,7 +14,7 @@ use Drupal\simpletest\WebTestBase; * * @group paragraphs */ -class ParagraphsTranslationTest extends WebTestBase { +class ParagraphsTranslationTest extends ParagraphsTestBase { /** * Modules to enable. @@ -22,17 +22,15 @@ class ParagraphsTranslationTest extends WebTestBase { * @var array */ public static $modules = array( - 'node', 'paragraphs_demo', 'content_translation', - 'block', 'link', ); /** * A user with admin permissions. * - * @var \Drupal\user\UserInterface $entity + * @var array */ protected $admin_user; @@ -41,26 +39,16 @@ class ParagraphsTranslationTest extends WebTestBase { */ protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('local_tasks_block'); - $this->drupalPlaceBlock('page_title_block'); - - $this->admin_user = $this->drupalCreateUser(array( + $this->loginAsAdmin([ 'administer site configuration', - 'administer nodes', 'create paragraphed_content_demo content', 'edit any paragraphed_content_demo content', 'delete any paragraphed_content_demo content', - 'administer paragraph form display', - 'administer paragraph fields', 'administer content translation', 'translate any entity', 'create content translations', 'administer languages', - 'administer content types', - )); - - $this->drupalLogin($this->admin_user); - + ]); $edit = [ 'settings[paragraph][nested_paragraph][translatable]' => TRUE, 'settings[paragraph][nested_paragraph][settings][language][language_alterable]' => TRUE,