BlockContentTestBase.php

Same filename in this branch
  1. 11.x core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php
Same filename and directory in other branches
  1. 9 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php
  2. 9 core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
  3. 8.9.x core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
  4. 8.9.x core/modules/block_content/src/Tests/BlockContentTestBase.php
  5. 8.9.x core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php
  6. 8.9.x core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
  7. 10 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php
  8. 10 core/modules/block_content/tests/src/Functional/BlockContentTestBase.php

Namespace

Drupal\Tests\block_content\Functional

File

core/modules/block_content/tests/src/Functional/BlockContentTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\block_content\Functional;

use Drupal\Tests\block_content\Traits\BlockContentCreationTrait;
use Drupal\Tests\BrowserTestBase;

/**
 * Sets up block content types.
 */
abstract class BlockContentTestBase extends BrowserTestBase {
  use BlockContentCreationTrait;
  
  /**
   * Profile to use.
   *
   * @var string
   */
  protected $profile = 'testing';
  
  /**
   * Admin user.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $adminUser;
  
  /**
   * Permissions to grant admin user.
   *
   * @var array
   */
  protected $permissions = [
    'administer blocks',
    'access block library',
    'administer block types',
    'administer block content',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'block',
    'block_content',
  ];
  
  /**
   * Whether or not to auto-create the basic block type during setup.
   *
   * @var bool
   */
  protected $autoCreateBasicBlockType = TRUE;
  
  /**
   * Sets the test up.
   */
  protected function setUp() : void {
    parent::setUp();
    if ($this->autoCreateBasicBlockType) {
      $this->createBlockContentType([
        'id' => 'basic',
      ], TRUE);
    }
    $this->adminUser = $this->drupalCreateUser($this->permissions);
    $this->drupalPlaceBlock('local_actions_block');
  }

}

Classes

Title Deprecated Summary
BlockContentTestBase Sets up block content types.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.