function ParagraphsTestBase::loginAsAdmin

Creates an user with admin permissions and log in.

Parameters

array $additional_permissions: Additional permissions that will be granted to admin user.

bool $reset_permissions: Flag to determine if default admin permissions will be replaced by $additional_permissions.

Return value

object Newly created and logged in user object.

107 calls to ParagraphsTestBase::loginAsAdmin()
MultilingualBehaviorTest::testMoveModeratedTranslatedNestedParagraphToLibrary in paragraphs/modules/paragraphs_library/tests/src/Functional/MultilingualBehaviorTest.php
Tests converting moderated translated nested paragraph into library.
ParagraphsAccessTest::setUp in paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php
ParagraphsAccessTest::setUp in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php
ParagraphsAccessTest::testParagraphAccessCheck in paragraphs/tests/src/Functional/WidgetStable/ParagraphsAccessTest.php
Tests the Paragraph access and permissions.
ParagraphsAccessTest::testParagraphAccessCheck in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php
Tests the paragraph translation.

... See full list

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsTestBase.php, line 82

Class

ParagraphsTestBase
Base class for tests.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

function loginAsAdmin($additional_permissions = [], $reset_permissions = FALSE) {
  $permissions = $this->admin_permissions;
  if ($reset_permissions) {
    $permissions = $additional_permissions;
  }
  elseif (!empty($additional_permissions)) {
    $permissions = array_merge($permissions, $additional_permissions);
  }
  $this->admin_user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($this->admin_user);
  return $this->admin_user;
}