drupalPlaceBlock example

'edit any page content',
      'view page revisions',
      'bypass node access',
      'access user profiles',
    ]);
  }

  /** * Checks that the Revision tab is displayed correctly. */
  public function testDisplayRevisionTab() {
    $this->drupalPlaceBlock('local_tasks_block');

    $this->drupalLogin($this->editor);

    // Set page revision setting 'create new revision'. This will mean new     // revisions are created by default when the node is edited.     $type = NodeType::load('page');
    $type->setNewRevision(TRUE);
    $type->save();

    // Create the node.     $node = $this->drupalCreateNode();

    
$author_2 = $this->drupalCreateUser();
    $node_2 = $this->drupalCreateNode([
      'uid' => $author_2->id(),
      'title' => 'Node 2',
      'body' => [
        0 => ['value' => 'Body 2', 'format' => 'full_html'],
      ],
      'promote' => NodeInterface::PROMOTED,
    ]);

    // Place a block, but only make it visible on full node page 2.     $block = $this->drupalPlaceBlock('views_block:comments_recent-block_1', [
      'visibility' => [
        'request_path' => [
          'pages' => '/node/' . $node_2->id(),
        ],
      ],
    ]);

    $cache_contexts = [
      'languages:' . LanguageInterface::TYPE_INTERFACE,
      'route',
      'theme',
      
'label' => 'Test block C',
      ],
      'stark_drupal' => [
        'weight' => '3',
        'id' => 'stark_drupal',
        'label' => 'Test block B',
      ],
    ];

    // Place the test blocks.     foreach ($test_blocks as $test_block) {
      $this->drupalPlaceBlock('system_powered_by_block', [
        'label' => $test_block['label'],
        'region' => $region,
        'weight' => $test_block['weight'],
        'id' => $test_block['id'],
      ]);
    }

    $this->drupalGet('');
    $test_content = $this->getSession()->getPage()->getContent();

    $controller = $this->container->get('entity_type.manager')->getStorage('block');
    
'access block library',
    'view any basic block content history',
    'revert any basic block content revisions',
  ];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    $this->drupalPlaceBlock('page_title_block');
  }

  /** * Tests revision revert. */
  public function testRevertForm(): void {
    $entity = $this->createBlockContent(save: FALSE)
      ->setRevisionCreationTime((new \DateTimeImmutable('11 January 2009 4pm'))->getTimestamp())
      ->setRevisionTranslationAffected(TRUE);
    $entity->setNewRevision();
    $entity->save();
    
protected $contentUser;
  protected $savedTitle;

  /** * Implement setUp(). */
  protected function setUp(): void {
    parent::setUp();

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

    $this->drupalPlaceBlock('page_title_block');

    $this->contentUser = $this->drupalCreateUser([
      'create page content',
      'access content',
      'administer themes',
      'administer site configuration',
      'link to any page',
    ]);
    $this->drupalLogin($this->contentUser);
  }

  
$this->searchNode = $node;
    // Link the node to itself to test that it's only indexed once. The content     // also needs the word "pizza" so we can use it as the search keyword.     $body_key = 'body[0][value]';
    $edit[$body_key] = Link::fromTextAndUrl($node->label()$node->toUrl())->toString() . ' pizza sandwich';
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');

    $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();

    // Enable the search block.     $this->drupalPlaceBlock('search_form_block');
    $this->drupalPlaceBlock('local_tasks_block', ['id' => 'local_tasks']);
    $this->drupalPlaceBlock('page_title_block');
  }

  /** * Verifies the search settings form. */
  public function testSearchSettingsPage() {

    // Test that the settings form displays the correct count of items left to index.     $this->drupalGet('admin/config/search/pages');
    
'translate interface',
      'administer entity_test fields',
    ]);
    // Create and login user.     $this->translatorUser = $this->drupalCreateUser($translator_permissions);
    $this->adminUser = $this->drupalCreateUser($admin_permissions);

    // Add languages.     foreach ($this->langcodes as $langcode) {
      ConfigurableLanguage::createFromLangcode($langcode)->save();
    }
    $this->drupalPlaceBlock('local_tasks_block');
    $this->drupalPlaceBlock('page_title_block');
  }

  /** * Tests the translation of field and field storage configuration. */
  public function testFieldConfigTranslation() {
    // Add a test field which has a translatable field setting and a     // translatable field storage setting.     $field_name = strtolower($this->randomMachineName());
    $field_storage = FieldStorageConfig::create([
      

  protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void {
    parent::setUp($import_test_views$modules);

    $this->enableViewsTestModule();

    $this->adminUser = $this->drupalCreateUser([
      'administer views',
      'administer menu',
    ]);
    $this->drupalPlaceBlock('system_menu_block:main');
    $this->drupalCreateContentType(['type' => 'page']);
  }

  /** * Tests that menu links using menu_link_content as parent are visible. */
  public function testHierarchicalMenuLinkVisibility() {
    $this->drupalLogin($this->adminUser);

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

    
protected static $modules = ['system', 'block', 'menu_link_content'];

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

    // Place the menu block, so menu trail gets built and cached. Showing the     // menu starting from the second level, so it is only shown when the active     // trail matches.     $this->drupalPlaceBlock(
      'system_menu_block:' . $this->menu,
      [
        'level' => 2,
      ]
    );

    // Menu content, where the privileged user has access and the anonymous does     // not have access. This route will be visited by both users. The privileged     // user should see the menu with the menu content item created below.     $parent_menu_link_content = MenuLinkContent::create([
      'title' => 'Admin overview',
      
protected $defaultTheme = 'stark';

  public function testCacheTagInvalidationUponInstallation() {
    // Warm the page cache.     $this->drupalGet('');
    $this->assertSession()->pageTextNotContains('Powered by Drupal');
    $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'config:block_list');

    // Install the block module, and place the "Powered by Drupal" block.     $this->container->get('module_installer')->install(['block', 'shortcut']);
    $this->rebuildContainer();
    $this->drupalPlaceBlock('system_powered_by_block');

    // Check the same page, block.module's hook_install() should have     // invalidated the 'rendered' cache tag to make blocks show up.     $this->drupalGet('');
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:block_list');
    $this->assertSession()->pageTextContains('Powered by Drupal');
  }

}

  protected $items;

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

    $this->drupalPlaceBlock('page_title_block');
    $this->drupalPlaceBlock('system_menu_block:main');
    $this->drupalPlaceBlock('local_actions_block', [
      'region' => 'content',
      'weight' => -100,
    ]);

    $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);

    // Create users.     $this->adminUser = $this->drupalCreateUser([
      'access administration pages',
      
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

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

    $this->drupalPlaceBlock('local_tasks_block');
  }

  /** * Tests non-default theme admin. */
  public function testNonDefaultBlockAdmin() {
    $admin_user = $this->drupalCreateUser([
      'administer blocks',
      'administer themes',
    ]);
    $this->drupalLogin($admin_user);
    
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

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

    $this->drupalPlaceBlock('system_menu_block:main');

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

    $workflow = $this->createEditorialWorkflow();
    $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'page');
    $workflow->save();
  }
$edit['admin_theme'] = 'claro';
    $this->drupalGet('admin/appearance');
    $this->submitForm($edit, 'Save configuration');

    // Define our block settings.     $settings = [
      'theme' => 'claro',
      'region' => 'header',
    ];

    // Place a block.     $block = $this->drupalPlaceBlock('local_tasks_block', $settings);

    // Open admin page.     $this->drupalGet('admin');

    // Check if contextual link classes are unavailable.     $this->assertSession()->responseNotContains('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
    $this->assertSession()->responseNotContains('contextual-region');
  }

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

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

    $this->drupalPlaceBlock('system_menu_block:main');
    $this->drupalPlaceBlock('page_title_block');

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

    $this->editor = $this->drupalCreateUser([
      'access administration pages',
      'administer content types',
      'administer menu',
      'create page content',
      'edit any page content',
      'delete any page content',
      
Home | Imprint | This part of the site doesn't use cookies.