Commit 50570ec5 authored by xjm's avatar xjm

Issue #3133033 by munish.kumar, xjm, Hardik_Patel_12, daffie, swatichouhan012:...

Issue #3133033 by munish.kumar, xjm, Hardik_Patel_12, daffie, swatichouhan012: Fix Drupal.Array.Array.LongLineDeclaration coding standard for instances of the drupalCreateUser() test method

(cherry picked from commit de32f3ca)
parent 4d51aabe
...@@ -46,7 +46,12 @@ protected function setUp() { ...@@ -46,7 +46,12 @@ protected function setUp() {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
} }
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']); $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_tasks_block'); $this->drupalPlaceBlock('local_tasks_block');
} }
......
...@@ -55,7 +55,13 @@ protected function setUp(): void { ...@@ -55,7 +55,13 @@ protected function setUp(): void {
* Tests creation of feeds with a language. * Tests creation of feeds with a language.
*/ */
public function testFeedLanguage() { public function testFeedLanguage() {
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer news feeds', 'access news feeds', 'create article content']); $admin_user = $this->drupalCreateUser([
'administer languages',
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
// Enable language selection for feeds. // Enable language selection for feeds.
......
...@@ -29,7 +29,12 @@ class ImportOpmlTest extends AggregatorTestBase { ...@@ -29,7 +29,12 @@ class ImportOpmlTest extends AggregatorTestBase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$admin_user = $this->drupalCreateUser(['administer news feeds', 'access news feeds', 'create article content', 'administer blocks']); $admin_user = $this->drupalCreateUser([
'administer news feeds',
'access news feeds',
'create article content',
'administer blocks',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
} }
......
...@@ -28,7 +28,10 @@ class BlockAdminThemeTest extends BrowserTestBase { ...@@ -28,7 +28,10 @@ class BlockAdminThemeTest extends BrowserTestBase {
*/ */
public function testAdminTheme() { public function testAdminTheme() {
// Create administrative user. // Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
// Ensure that access to block admin page is denied when theme is not // Ensure that access to block admin page is denied when theme is not
......
...@@ -56,7 +56,10 @@ protected function setUp(): void { ...@@ -56,7 +56,10 @@ protected function setUp(): void {
parent::setUp(); parent::setUp();
// Create an admin user, log in and enable test blocks. // Create an admin user, log in and enable test blocks.
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'access administration pages']); $this->adminUser = $this->drupalCreateUser([
'administer blocks',
'access administration pages',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// Create additional users to test caching modes. // Create additional users to test caching modes.
......
...@@ -28,7 +28,10 @@ class BlockDemoTest extends BrowserTestBase { ...@@ -28,7 +28,10 @@ class BlockDemoTest extends BrowserTestBase {
*/ */
public function testBlockDemo() { public function testBlockDemo() {
// Create administrative user. // Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
// Confirm we have access to the block demo page for the default theme. // Confirm we have access to the block demo page for the default theme.
......
...@@ -33,7 +33,10 @@ class BlockLanguageTest extends BrowserTestBase { ...@@ -33,7 +33,10 @@ class BlockLanguageTest extends BrowserTestBase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages']); $this->adminUser = $this->drupalCreateUser([
'administer blocks',
'administer languages',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// Add predefined language. // Add predefined language.
......
...@@ -32,7 +32,10 @@ class BlockXssTest extends BrowserTestBase { ...@@ -32,7 +32,10 @@ class BlockXssTest extends BrowserTestBase {
* Tests that nothing is escaped other than the blocks explicitly tested. * Tests that nothing is escaped other than the blocks explicitly tested.
*/ */
public function testNoUnexpectedEscaping() { public function testNoUnexpectedEscaping() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages'])); $this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$this->drupalGet(Url::fromRoute('block.admin_display')); $this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block'); $this->clickLink('Place block');
$this->assertNoEscaped('<'); $this->assertNoEscaped('<');
...@@ -49,7 +52,10 @@ public function testXssInTitle() { ...@@ -49,7 +52,10 @@ public function testXssInTitle() {
$this->drupalGet(''); $this->drupalGet('');
$this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.'); $this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.');
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages'])); $this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$default_theme = $this->config('system.theme')->get('default'); $default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/list/' . $default_theme); $this->drupalGet('admin/structure/block/list/' . $default_theme);
$this->assertNoRaw("<script>alert('XSS subject');</script>", 'The block title was properly sanitized in Block Plugin UI Admin page.'); $this->assertNoRaw("<script>alert('XSS subject');</script>", 'The block title was properly sanitized in Block Plugin UI Admin page.');
...@@ -61,7 +67,10 @@ public function testXssInTitle() { ...@@ -61,7 +67,10 @@ public function testXssInTitle() {
public function testXssInCategory() { public function testXssInCategory() {
$this->container->get('module_installer')->install(['block_test']); $this->container->get('module_installer')->install(['block_test']);
$this->drupalPlaceBlock('test_xss_title'); $this->drupalPlaceBlock('test_xss_title');
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages'])); $this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$this->drupalGet(Url::fromRoute('block.admin_display')); $this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block'); $this->clickLink('Place block');
$this->assertNoRaw("<script>alert('XSS category');</script>"); $this->assertNoRaw("<script>alert('XSS category');</script>");
......
...@@ -36,7 +36,10 @@ protected function setUp(): void { ...@@ -36,7 +36,10 @@ protected function setUp(): void {
* Test non-default theme admin. * Test non-default theme admin.
*/ */
public function testNonDefaultBlockAdmin() { public function testNonDefaultBlockAdmin() {
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
$new_theme = 'bartik'; $new_theme = 'bartik';
\Drupal::service('theme_installer')->install([$new_theme]); \Drupal::service('theme_installer')->install([$new_theme]);
......
...@@ -65,7 +65,10 @@ protected function setUp($import_test_views = TRUE): void { ...@@ -65,7 +65,10 @@ protected function setUp($import_test_views = TRUE): void {
* Tests default and custom block categories. * Tests default and custom block categories.
*/ */
public function testBlockCategory() { public function testBlockCategory() {
$this->drupalLogin($this->drupalCreateUser(['administer views', 'administer blocks'])); $this->drupalLogin($this->drupalCreateUser([
'administer views',
'administer blocks',
]));
// Create a new view in the UI. // Create a new view in the UI.
$edit = []; $edit = [];
...@@ -368,7 +371,11 @@ public function testBlockEmptyRendering() { ...@@ -368,7 +371,11 @@ public function testBlockEmptyRendering() {
* Tests the contextual links on a Views block. * Tests the contextual links on a Views block.
*/ */
public function testBlockContextualLinks() { public function testBlockContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links', 'administer blocks'])); $this->drupalLogin($this->drupalCreateUser([
'administer views',
'access contextual links',
'administer blocks',
]));
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1'); $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1'); $cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$this->drupalGet('test-page'); $this->drupalGet('test-page');
......
...@@ -31,7 +31,10 @@ class BlockContentListTest extends BlockContentTestBase { ...@@ -31,7 +31,10 @@ class BlockContentListTest extends BlockContentTestBase {
* Tests the custom block listing page. * Tests the custom block listing page.
*/ */
public function testListing() { public function testListing() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content'); $this->drupalGet('admin/structure/block/block-content');
// Test for the page title. // Test for the page title.
......
...@@ -34,7 +34,10 @@ class BlockContentListViewsTest extends BlockContentTestBase { ...@@ -34,7 +34,10 @@ class BlockContentListViewsTest extends BlockContentTestBase {
* Tests the custom block listing page. * Tests the custom block listing page.
*/ */
public function testListing() { public function testListing() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content'); $this->drupalGet('admin/structure/block/block-content');
// Test for the page title. // Test for the page title.
......
...@@ -53,8 +53,24 @@ protected function setUp(): void { ...@@ -53,8 +53,24 @@ protected function setUp(): void {
$this->drupalPlaceBlock('page_title_block'); $this->drupalPlaceBlock('page_title_block');
// Create users. // Create users.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']); $this->bookAuthor = $this->drupalCreateUser([
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration']); 'create new books',
'create book content',
'edit own book content',
'add content to books',
]);
$this->adminUser = $this->drupalCreateUser([
'create new books',
'create book content',
'edit any book content',
'delete any book content',
'add content to books',
'administer blocks',
'administer permissions',
'administer book outlines',
'administer content types',
'administer site configuration',
]);
} }
/** /**
......
...@@ -46,7 +46,16 @@ protected function setUp(): void { ...@@ -46,7 +46,16 @@ protected function setUp(): void {
$workflow->save(); $workflow->save();
// We need a user with additional content moderation permissions. // We need a user with additional content moderation permissions.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books', 'access printer-friendly version', 'view any unpublished content', 'use editorial transition create_new_draft', 'use editorial transition publish']); $this->bookAuthor = $this->drupalCreateUser([
'create new books',
'create book content',
'edit own book content',
'add content to books',
'access printer-friendly version',
'view any unpublished content',
'use editorial transition create_new_draft',
'use editorial transition publish',
]);
} }
/** /**
......
...@@ -66,10 +66,32 @@ protected function setUp(): void { ...@@ -66,10 +66,32 @@ protected function setUp(): void {
node_access_rebuild(); node_access_rebuild();
// Create users. // Create users.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']); $this->bookAuthor = $this->drupalCreateUser([
$this->webUser = $this->drupalCreateUser(['access printer-friendly version', 'node test view']); 'create new books',
$this->webUserWithoutNodeAccess = $this->drupalCreateUser(['access printer-friendly version']); 'create book content',
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration']); 'edit own book content',
'add content to books',
]);
$this->webUser = $this->drupalCreateUser([
'access printer-friendly version',
'node test view',
]);
$this->webUserWithoutNodeAccess = $this->drupalCreateUser([
'access printer-friendly version',
]);
$this->adminUser = $this->drupalCreateUser([
'create new books',
'create book content',
'edit any book content',
'delete any book content',
'add content to books',
'administer blocks',
'administer permissions',
'administer book outlines',
'node test view',
'administer content types',
'administer site configuration',
]);
} }
/** /**
...@@ -562,7 +584,11 @@ public function testBookNavigationBlockOnUnpublishedBook() { ...@@ -562,7 +584,11 @@ public function testBookNavigationBlockOnUnpublishedBook() {
$this->createBook(); $this->createBook();
// Create administrator user. // Create administrator user.
$administratorUser = $this->drupalCreateUser(['administer blocks', 'administer nodes', 'bypass node access']); $administratorUser = $this->drupalCreateUser([
'administer blocks',
'administer nodes',
'bypass node access',
]);
$this->drupalLogin($administratorUser); $this->drupalLogin($administratorUser);
// Enable the block with "Show block only on book pages" mode. // Enable the block with "Show block only on book pages" mode.
......
...@@ -72,8 +72,16 @@ protected function setUp(): void { ...@@ -72,8 +72,16 @@ protected function setUp(): void {
'name' => 'Article', 'name' => 'Article',
]); ]);
$this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']); $this->untrustedUser = $this->drupalCreateUser([
$this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html']); 'create article content',
'edit any article content',
]);
$this->normalUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format filtered_html',
'use text format full_html',
]);
} }
/** /**
......
...@@ -57,7 +57,10 @@ protected function setUp(): void { ...@@ -57,7 +57,10 @@ protected function setUp(): void {
]); ]);
$editor->save(); $editor->save();
$this->adminUser = $this->drupalCreateUser(['administer filters', 'translate configuration']); $this->adminUser = $this->drupalCreateUser([
'administer filters',
'translate configuration',
]);
ConfigurableLanguage::createFromLangcode('de')->save(); ConfigurableLanguage::createFromLangcode('de')->save();
} }
......
...@@ -60,7 +60,11 @@ public function testBookCommentPrint() { ...@@ -60,7 +60,11 @@ public function testBookCommentPrint() {
]); ]);
$comment->save(); $comment->save();
$commenting_user = $this->drupalCreateUser(['access printer-friendly version', 'access comments', 'post comments']); $commenting_user = $this->drupalCreateUser([
'access printer-friendly version',
'access comments',
'post comments',
]);
$this->drupalLogin($commenting_user); $this->drupalLogin($commenting_user);
$this->drupalGet('node/' . $book_node->id()); $this->drupalGet('node/' . $book_node->id());
......
...@@ -191,7 +191,10 @@ public function testCommentFieldCreate() { ...@@ -191,7 +191,10 @@ public function testCommentFieldCreate() {
*/ */
public function testCommentInstallAfterContentModule() { public function testCommentInstallAfterContentModule() {
// Create a user to do module administration. // Create a user to do module administration.
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']); $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer modules',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// Drop default comment field added in CommentTestBase::setup(). // Drop default comment field added in CommentTestBase::setup().
...@@ -233,7 +236,12 @@ public function testCommentInstallAfterContentModule() { ...@@ -233,7 +236,12 @@ public function testCommentInstallAfterContentModule() {
// Try to post a comment on each node. A failure will be triggered if the // Try to post a comment on each node. A failure will be triggered if the
// comment body is missing on one of these forms, due to postComment() // comment body is missing on one of these forms, due to postComment()
// asserting that the body is actually posted correctly. // asserting that the body is actually posted correctly.
$this->webUser = $this->drupalCreateUser(['access content', 'access comments', 'post comments', 'skip comment approval']); $this->webUser = $this->drupalCreateUser([
'access content',
'access comments',
'post comments',
'skip comment approval',
]);
$this->drupalLogin($this->webUser); $this->drupalLogin($this->webUser);
$this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName()); $this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName());
} }
......
...@@ -45,7 +45,17 @@ protected function setUp(): void { ...@@ -45,7 +45,17 @@ protected function setUp(): void {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create and log in user. // Create and log in user.
$admin_user = $this->drupalCreateUser(['administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval']); $admin_user = $this->drupalCreateUser([
'administer site configuration',
'administer languages',
'access administration pages',
'administer content types',
'administer comments',
'create article content',
'access comments',
'post comments',
'skip comment approval',
]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
// Add language. // Add language.
......
...@@ -128,7 +128,12 @@ public function testCommentPreviewDuplicateSubmission() { ...@@ -128,7 +128,12 @@ public function testCommentPreviewDuplicateSubmission() {
* Tests comment edit, preview, and save. * Tests comment edit, preview, and save.
*/ */
public function testCommentEditPreviewSave() { public function testCommentEditPreviewSave() {
$web_user = $this->drupalCreateUser(['access comments', 'post comments', 'skip comment approval', 'edit own comments']); $web_user = $this->drupalCreateUser([
'access comments',
'post comments',
'skip comment approval',
'edit own comments',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->setCommentPreview(DRUPAL_OPTIONAL); $this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE); $this->setCommentForm(TRUE);
......
...@@ -35,7 +35,9 @@ class ConfigDependencyWebTest extends BrowserTestBase { ...@@ -35,7 +35,9 @@ class ConfigDependencyWebTest extends BrowserTestBase {
* @see \Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait * @see \Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait
*/ */
public function testConfigDependencyDeleteFormTrait() { public function testConfigDependencyDeleteFormTrait() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); $this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */ /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container->get('entity_type.manager')->getStorage('config_test'); $storage = $this->container->get('entity_type.manager')->getStorage('config_test');