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() {
$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->drupalPlaceBlock('local_tasks_block');
}
......
......@@ -55,7 +55,13 @@ protected function setUp(): void {
* Tests creation of feeds with a language.
*/
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);
// Enable language selection for feeds.
......
......@@ -29,7 +29,12 @@ class ImportOpmlTest extends AggregatorTestBase {
protected function setUp(): void {
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);
}
......
......@@ -28,7 +28,10 @@ class BlockAdminThemeTest extends BrowserTestBase {
*/
public function testAdminTheme() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
// Ensure that access to block admin page is denied when theme is not
......
......@@ -56,7 +56,10 @@ protected function setUp(): void {
parent::setUp();
// 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);
// Create additional users to test caching modes.
......
......@@ -28,7 +28,10 @@ class BlockDemoTest extends BrowserTestBase {
*/
public function testBlockDemo() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
// Confirm we have access to the block demo page for the default theme.
......
......@@ -33,7 +33,10 @@ class BlockLanguageTest extends BrowserTestBase {
protected function setUp(): void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages']);
$this->adminUser = $this->drupalCreateUser([
'administer blocks',
'administer languages',
]);
$this->drupalLogin($this->adminUser);
// Add predefined language.
......
......@@ -32,7 +32,10 @@ class BlockXssTest extends BrowserTestBase {
* Tests that nothing is escaped other than the blocks explicitly tested.
*/
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->clickLink('Place block');
$this->assertNoEscaped('<');
......@@ -49,7 +52,10 @@ public function testXssInTitle() {
$this->drupalGet('');
$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');
$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.');
......@@ -61,7 +67,10 @@ public function testXssInTitle() {
public function testXssInCategory() {
$this->container->get('module_installer')->install(['block_test']);
$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->clickLink('Place block');
$this->assertNoRaw("<script>alert('XSS category');</script>");
......
......@@ -36,7 +36,10 @@ protected function setUp(): void {
* Test non-default theme admin.
*/
public function testNonDefaultBlockAdmin() {
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
$new_theme = 'bartik';
\Drupal::service('theme_installer')->install([$new_theme]);
......
......@@ -65,7 +65,10 @@ protected function setUp($import_test_views = TRUE): void {
* Tests default and custom block categories.
*/
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.
$edit = [];
......@@ -368,7 +371,11 @@ public function testBlockEmptyRendering() {
* Tests the contextual links on a Views block.
*/
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');
$cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$this->drupalGet('test-page');
......
......@@ -31,7 +31,10 @@ class BlockContentListTest extends BlockContentTestBase {
* Tests the custom block listing page.
*/
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');
// Test for the page title.
......
......@@ -34,7 +34,10 @@ class BlockContentListViewsTest extends BlockContentTestBase {
* Tests the custom block listing page.
*/
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');
// Test for the page title.
......
......@@ -53,8 +53,24 @@ protected function setUp(): void {
$this->drupalPlaceBlock('page_title_block');
// Create users.
$this->bookAuthor = $this->drupalCreateUser(['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']);
$this->bookAuthor = $this->drupalCreateUser([
'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 {
$workflow->save();
// 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 {
node_access_rebuild();
// Create users.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', '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']);
$this->bookAuthor = $this->drupalCreateUser([
'create new books',
'create book content',
'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() {
$this->createBook();
// 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);
// Enable the block with "Show block only on book pages" mode.
......
......@@ -72,8 +72,16 @@ protected function setUp(): void {
'name' => 'Article',
]);
$this->untrustedUser = $this->drupalCreateUser(['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']);
$this->untrustedUser = $this->drupalCreateUser([
'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 {
]);
$editor->save();
$this->adminUser = $this->drupalCreateUser(['administer filters', 'translate configuration']);
$this->adminUser = $this->drupalCreateUser([
'administer filters',
'translate configuration',
]);
ConfigurableLanguage::createFromLangcode('de')->save();
}
......
......@@ -60,7 +60,11 @@ public function testBookCommentPrint() {
]);
$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->drupalGet('node/' . $book_node->id());
......
......@@ -191,7 +191,10 @@ public function testCommentFieldCreate() {
*/
public function testCommentInstallAfterContentModule() {
// 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);
// Drop default comment field added in CommentTestBase::setup().
......@@ -233,7 +236,12 @@ public function testCommentInstallAfterContentModule() {
// 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()
// 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->postComment($book_node, $this->randomMachineName(), $this->randomMachineName());
}
......
......@@ -45,7 +45,17 @@ protected function setUp(): void {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// 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);
// Add language.
......
......@@ -128,7 +128,12 @@ public function testCommentPreviewDuplicateSubmission() {
* Tests comment edit, preview, and save.
*/
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->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
......
......@@ -35,7 +35,9 @@ class ConfigDependencyWebTest extends BrowserTestBase {
* @see \Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait
*/
public function testConfigDependencyDeleteFormTrait() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container->get('entity_type.manager')->getStorage('config_test');
......
......@@ -25,7 +25,9 @@ class ConfigEntityFormOverrideTest extends BrowserTestBase {
* Tests that overrides do not affect forms or listing screens.
*/
public function testFormsWithOverrides() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$original_label = 'Default';
$overridden_label = 'Overridden label';
......
......@@ -41,7 +41,10 @@ protected function setUp(): void {
*/
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
// Get the list page.
$this->drupalGet('admin/structure/config_test');
......
......@@ -156,7 +156,10 @@ public function testList() {
*/
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
// Get the list callback page.
$this->drupalGet('admin/structure/config_test');
......@@ -254,7 +257,9 @@ public function testListUI() {
* Test paging.
*/
public function testPager() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$storage = \Drupal::service('entity_type.manager')->getListBuilder('config_test')->getStorage();
......
......@@ -27,7 +27,9 @@ class ConfigEntityStatusUITest extends BrowserTestBase {
* Tests status operations.
*/
public function testCRUD() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$id = strtolower($this->randomMachineName());
$edit = [
......
......@@ -236,7 +236,9 @@ public function testCRUD() {
* Tests CRUD operations through the UI.
*/
public function testCRUDUI() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$id = strtolower($this->randomMachineName());
$label1 = $this->randomMachineName();
......
......@@ -21,7 +21,10 @@ class ConfigFormOverrideTest extends BrowserTestBase {
* Tests that overrides do not affect forms.
*/
public function testFormsWithOverrides() {
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
$overridden_name = 'Site name global conf override';
......
......@@ -34,7 +34,11 @@ class ConfigInstallWebTest extends BrowserTestBase {
protected function setUp(): void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']);
$this->adminUser = $this->drupalCreateUser([
'administer modules',
'administer themes',
'administer site configuration',
]);
// Ensure the global variable being asserted by this test does not exist;
// a previous test executed in this request/process might have set it.
......
......@@ -40,7 +40,10 @@ protected function setUp(): void {
* Tests translating the site name.
*/
public function testSiteNameTranslation() {
$adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']);
$adminUser = $this->drupalCreateUser([
'administer site configuration',
'administer languages',
]);
$this->drupalLogin($adminUser);
// Add a custom language.
......
......@@ -25,7 +25,9 @@ class ConfigEntityTest extends WebDriverTestBase {
* Tests ajax operations through the UI on 'Add' page.
*/
public function testAjaxOnAddPage() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
......
......@@ -57,11 +57,19 @@ protected function setUp(): void {
parent::setUp();
// Create an admin user.
$this->adminUser = $this->drupalCreateUser(['administer contact forms', 'administer users', 'administer account settings', 'access site reports']);