setUpCurrentUser example


  public function assertTextSummary(string $text, string $expected, ?string $format = NULL, int $size = NULL): void {
    $summary = text_summary($text$format$size);
    $this->assertSame($expected$summarynew FormattableMarkup('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', ['@actual' => $summary, '@expected' => $expected]));
  }

  /** * Tests required summary. */
  public function testRequiredSummary() {
    $this->installEntitySchema('entity_test');
    $this->setUpCurrentUser();
    $field_definition = FieldStorageConfig::create([
      'field_name' => 'test_textwithsummary',
      'type' => 'text_with_summary',
      'entity_type' => 'entity_test',
      'cardinality' => 1,
      'settings' => [
        'max_length' => 200,
      ],
    ]);
    $field_definition->save();

    
protected $entityRepository;

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

    $this->entityTypeManager = $this->container->get('entity_type.manager');
    $this->entityRepository = $this->container->get('entity.repository');

    $this->setUpCurrentUser();

    $this->installEntitySchema('entity_test');
    $this->installEntitySchema('entity_test_rev');
    $this->installEntitySchema('entity_test_mul');
    $this->installEntitySchema('entity_test_mulrev');

    $this->installConfig(['system', 'language']);
    ConfigurableLanguage::createFromLangcode('it')
      ->setWeight(1)
      ->save();
    ConfigurableLanguage::createFromLangcode('ro')
      
'node',
    'text',
    'path_alias',
  ];

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

    $this->setUpCurrentUser();

    $this->installSchema('node', ['node_access']);

    $this->installEntitySchema('workspace');
    $this->installSchema('workspaces', ['workspace_association']);
    $this->installEntitySchema('node');
    $this->installEntitySchema('path_alias');

    $this->installConfig(['filter', 'node', 'system']);

    $this->createContentType(['type' => 'page']);

    

  public function setUp(): void {
    parent::setUp();

    $permissions = ['view own unpublished content'];
    $this->authorAccount = $this->setUpCurrentUser([
      'name' => 'author',
      'pass' => 'authorPass',
    ]$permissions);

    NodeType::create([
      'type' => 'page',
    ])->save();

    $home_page_link = $this->createMenuItem([
      'title' => 'Home',
      'description' => 'Links to the home page.',
      
'content_translation',
    'language',
    'menu_link_content',
    'menu_ui',
  ];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->setUpCurrentUser();
    $this->installEntitySchema('menu_link_content');
    $this->executeMigrations([
      'language',
      'd6_language_content_settings',
      'd6_node',
      'd6_node_translation',
      'd6_menu',
      'd6_menu_links',
      'node_translation_menu_links',
    ]);
  }

  

  protected function setUp(): void {
    parent::setUp();
    $this->createUser();
  }

  /** * Tests that the current user is set up correctly. */
  public function testSetUpCurrentUser() {
    $account = $this->setUpCurrentUser();
    $current_user = \Drupal::currentUser();
    $this->assertSame($account->id()$current_user->id());
  }

}

    FieldStorageConfig::create(['field_name' => 'field_image', 'cardinality' => 1] + $field_storage_config)->save();
    FieldStorageConfig::create(['field_name' => 'field_images', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED] + $field_storage_config)->save();
    $field_config = [
      'entity_type' => 'node',
      'bundle' => 'referencer',
    ];
    FieldConfig::create(['field_name' => 'field_image', 'label' => 'Image'] + $field_config)->save();
    FieldConfig::create(['field_name' => 'field_images', 'label' => 'Images'] + $field_config)->save();

    // Set up the test data.     $this->setUpCurrentUser([]['access content']);
    $this->user1 = User::create([
      'name' => $this->randomMachineName(),
      'mail' => $this->randomMachineName() . '@example.com',
      'uuid' => static::$userIds[0],
      'uid'  => static::$userUids[0],
    ]);
    $this->user1->save();
    $this->user2 = User::create([
      'name' => $this->randomMachineName(),
      'mail' => $this->randomMachineName() . '@example.com',
      'uuid' => static::$userIds[1],
      
'content_translation',
    'language',
    'menu_ui',
  ];

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

    $this->setUpCurrentUser();

    $this->installEntitySchema('node');
    $this->installConfig(['node']);
    $this->installSchema('node', ['node_access']);
    $this->migrateUsers(FALSE);
    $this->migrateFields();

    $this->executeMigrations([
      'language',
      'd6_language_types',
      'd6_language_negotiation_settings',
      
'menu_link_content',
    'language',
    'content_translation',
  ];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->migrateContent();
    $this->setUpCurrentUser();
    $this->installEntitySchema('menu_link_content');
    $this->executeMigrations([
      'language',
      'd6_menu',
      'd6_menu_links',
      'd6_menu_links_translation',
    ]);
  }

  /** * Tests migration of menu links. */

  protected $adminUser;

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

    // Create the anonymous user account and set it as current user.     $this->setUpCurrentUser(['uid' => 0]);

    $this->installEntitySchema('entity_test');
    $this->installConfig(['user']);

    // Create some test entities.     for ($i = 0; $i < 5; $i++) {
      EntityTest::create(['name' => $this->randomString()])->save();
    }

    // Create and admin user.     $this->adminUser = $this->createUser(['view test entity'], FALSE, TRUE);

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

    parent::setUp();

    $this->userController = UserController::create(\Drupal::getContainer());

    // Create and log in a user.     $this->user = $this->setUpCurrentUser();

  }

  /** * Tests the redirection to a user edit page. * * @covers ::userEditPage */
  public function testUserEditPage() {

    $response = $this->userController->userEditPage();

    
'link',
    'menu_link_content',
    'menu_ui',
  ];

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

    $this->setUpCurrentUser();
    $this->installEntitySchema('menu_link_content');
    $this->executeMigrations([
      'language',
      'd6_language_content_menu_settings',
      'd6_menu',
      'd6_menu_links',
      'd6_menu_links_localized',
    ]);
  }

  /** * Tests migration of menu link localized translations. */
/** * Tests correct processing of link fields. * * This overlaps with \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest to * ensure that root-relative links also work in a scenario without * subdirectory. */
  public function testLink() {
    // Set up the current user as uid 1 so the test doesn't need to deal with     // permission.     $this->setUpCurrentUser(['uid' => 1]);

    $node = $this->createNode([
      'type' => 'article',
      'title' => 'Article title',
      'body' => [
        0 => [
          'value' => 'A paragraph',
          'format' => filter_default_format(),
        ],
      ],
    ]);

    
'outbound_processing_test',
    'url_alter_test',
    'user',
  ];

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

    $this->setUpCurrentUser(['uid' => 0]);
    $this->installEntitySchema('menu_link_content');

    // Ensure that the weight of module_link_content is higher than system.     // @see menu_link_content_install()     module_set_weight('menu_link_content', 1);
  }

  /** * Tests bubbleable metadata of menu links' outbound route/path processing. */
  public function testOutboundPathAndRouteProcessing() {
    

  protected static $modules = ['entity_test', 'user'];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installEntitySchema('entity_test_rev');
    $this->installEntitySchema('user');
    $this->setUpCurrentUser(['uid' => 1]);
  }

  /** * Tests revision access for revision overview. * * Tests routes which do not need a specific revision parameter. */
  public function testOperationAccessOverview(): void {
    $entity = EntityTestRev::create()
      ->setName('first revision');
    $entity->save();
    
Home | Imprint | This part of the site doesn't use cookies.