drupalCreateUser example


  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Create test user.     $admin_user = $this->drupalCreateUser([
      'synchronize configuration',
      'access content',
      'access administration pages',
      'administer site configuration',
      'administer content types',
      'administer nodes',
      'bypass node access',
      'administer node fields',
      'administer node display',
    ]);
    $this->drupalLogin($admin_user);
  }
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->drupalCreateUser([
      'administer taxonomy',
      'bypass node access',
    ]));
    $this->vocabulary = $this->createVocabulary();
    $this->fieldName = 'taxonomy_' . $this->vocabulary->id();

    $handler_settings = [
      'target_bundles' => [
        $this->vocabulary->id() => $this->vocabulary->id(),
      ],
      'auto_create' => TRUE,
    ];
protected $searchNode;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);

    // Log in as a user that can create and search content.     $this->searchUser = $this->drupalCreateUser([
      'search content',
      'administer search',
      'administer nodes',
      'bypass node access',
      'access user profiles',
      'administer users',
      'administer blocks',
      'access site reports',
    ]);
    $this->drupalLogin($this->searchUser);

    
/** * Tests access to routes protected by CSRF request header requirements. * * This checks one route that uses _csrf_request_header_token. */
  public function testRouteAccess() {
    $client = $this->getHttpClient();
    $csrf_token_path = 'session/token';
    // Test using the current path.     $route_name = 'csrf_test.protected';
    $user = $this->drupalCreateUser();
    $this->drupalLogin($user);

    $csrf_token = $this->drupalGet($csrf_token_path);
    $url = Url::fromRoute($route_name)
      ->setAbsolute(TRUE)
      ->toString();
    $post_options = [
      'headers' => ['Accept' => 'text/plain'],
      'http_errors' => FALSE,
    ];

    

  protected $adminUser;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->adminUser = $this->drupalCreateUser([
      'access content',
      'access administration pages',
      'administer site configuration',
      'administer users',
      'administer permissions',
      'administer content types',
      'administer node fields',
      'administer node display',
      'administer nodes',
      'bypass node access',
    ]);
    
$this->container->get('config.factory')->getEditable('system.theme')->set('default', 'big_pipe_test_theme')->save();
  }

  /** * Ensure BigPipe works despite inline JS containing the string "</body>". * * @see https://www.drupal.org/node/2678662 */
  public function testMultipleClosingBodies_2678662() {
    $this->assertTrue($this->container->get('module_installer')->install(['render_placeholder_message_test'], TRUE), 'Installed modules.');

    $this->drupalLogin($this->drupalCreateUser());
    $this->drupalGet(Url::fromRoute('big_pipe_regression_test.2678662'));

    // Confirm that AJAX behaviors were instantiated, if not, this points to a     // JavaScript syntax error.     $javascript = <<<JS (function(){ return Object.keys(Drupal.ajax.instances).length > 0; }()) JS;
    $this->assertJsCondition($javascript);

    
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Create Basic page node type.     $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);

    // Setup users.     $admin_user = $this->drupalCreateUser([
      'administer languages',
      'administer content types',
      'access administration pages',
      'create page content',
      'edit own page content',
    ]);
    $this->drupalLogin($admin_user);

    // Add a new language.     ConfigurableLanguage::createFromLangcode('it')->save();

    
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $admin = $this->drupalCreateUser([
      'administer workflows',
    ]);
    $this->drupalLogin($admin);
  }

  /** * Tests creating a new workflow using the content moderation plugin. */
  public function testNewWorkflow() {
    $types[] = $this->createContentType();
    $types[] = $this->createContentType();
    
$this->mediaFile = Media::create([
      'bundle' => 'file',
      'name' => 'Information about screaming hairy armadillo',
      'field_media_file' => [
        [
          'target_id' => 2,
        ],
      ],
    ]);
    $this->mediaFile->save();

    $this->adminUser = $this->drupalCreateUser([
      'use text format filtered_html',
    ]);
    $this->drupalLogin($this->adminUser);
  }

  /** * Tests the media entity metadata API. */
  public function testApi() {
    $path = '/ckeditor5/filtered_html/media-entity-metadata';
    $token = $this->container->get('csrf_token')->get(ltrim($path, '/'));
    
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $user = $this->drupalCreateUser([
      'access administration pages',
      'administer languages',
      'administer content types',
    ]);
    $this->drupalLogin($user);
  }

  /** * Tests the language settings have been saved. */
  public function testLanguageConfigurationElement() {
    

  public function testBatchProgressPageTheme() {
    // Make sure that the page which starts the batch (an administrative page)     // is using a different theme than would normally be used by the batch API.     $this->container->get('theme_installer')->install(['claro', 'olivero']);
    $this->config('system.theme')
      ->set('default', 'olivero')
      ->set('admin', 'claro')
      ->save();

    // Log in as an administrator who can see the administrative theme.     $admin_user = $this->drupalCreateUser(['view the administration theme']);
    $this->drupalLogin($admin_user);
    // Visit an administrative page that runs a test batch, and check that the     // theme that was used during batch execution (which the batch callback     // function saved as a variable) matches the theme used on the     // administrative page.     $this->drupalGet('admin/batch-test/test-theme');
    // The stack should contain the name of the theme used on the progress     // page.     $this->assertEquals(['claro']batch_test_stack(), 'A progressive batch correctly uses the theme of the page that started the batch.');
  }

  


  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->fileUrlGenerator = $this->container->get('file_url_generator');

    // Create user.     $this->adminUser = $this->drupalCreateUser([
      'administer responsive images',
      'access content',
      'access administration pages',
      'administer site configuration',
      'administer content types',
      'administer node display',
      'administer nodes',
      'create article content',
      'edit any article content',
      'delete any article content',
      'administer image styles',
    ]);

  private $updateUser;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    require_once $this->root . '/core/includes/update.inc';
    $this->updateUrl = Url::fromRoute('system.db_update')->setAbsolute()->toString();
    $this->updateUser = $this->drupalCreateUser([
      'administer software updates',
    ]);
  }

  public function testWith7x() {
    /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
    $update_registry = \Drupal::service('update.update_hook_registry');

    // Ensure that the minimum schema version is 8000, despite 7200 update     // hooks and a 7XXX hook_update_last_removed().     $this->assertEquals(8000, $update_registry->getInstalledVersion('update_test_with_7x'));

    

class LanguageBlockSettingsVisibilityTest extends BrowserTestBase {

  protected static $modules = ['block', 'language'];

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  public function testUnnecessaryLanguageSettingsVisibility() {
    $admin_user = $this->drupalCreateUser([
      'administer languages',
      'access administration pages',
      'administer blocks',
    ]);
    $this->drupalLogin($admin_user);
    $this->drupalGet('admin/config/regional/language/add');
    $this->submitForm(['predefined_langcode' => 'hu'], 'Add language');
    $this->drupalGet('admin/structure/block/add/system_menu_block:admin/stark');
    $this->assertSession()->fieldNotExists("edit-visibility-language-langcodes-und");
    $this->assertSession()->fieldNotExists("edit-visibility-language-langcodes-zxx");
    $this->assertSession()->fieldExists("edit-visibility-language-langcodes-en");
    
'administer shortcuts',
      'administer site configuration',
      'administer taxonomy',
      'administer account settings',
      'administer languages',
      'administer image styles',
      'administer responsive images',
      'translate configuration',
    ];

    // Create and log in user.     $this->adminUser = $this->drupalCreateUser($permissions);
    $this->drupalLogin($this->adminUser);

    // Enable import of translations. By default this is disabled for automated     // tests.     $this->config('locale.settings')
      ->set('translation.import_enabled', TRUE)
      ->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
      ->save();
    $this->drupalPlaceBlock('local_tasks_block');
  }

  
Home | Imprint | This part of the site doesn't use cookies.