You are here

abstract class EntityLegalTestBase in Entity Legal 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Tests/EntityLegalTestBase.php \Drupal\entity_legal\Tests\EntityLegalTestBase
  2. 4.0.x src/Tests/EntityLegalTestBase.php \Drupal\entity_legal\Tests\EntityLegalTestBase

Common Simpletest class for all legal tests.

Hierarchy

Expanded class hierarchy of EntityLegalTestBase

File

src/Tests/EntityLegalTestBase.php, line 11

Namespace

Drupal\entity_legal\Tests
View source
abstract class EntityLegalTestBase extends WebTestBase {
  use EntityLegalTestTrait;

  /**
   * The administrative user to use for tests.
   *
   * @var \Drupal\user\Entity\User
   */
  protected $adminUser;

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'block',
    'entity_legal',
    'field_ui',
    'token',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->adminUser = $this
      ->drupalCreateUser([
      'administer entity legal',
      'administer permissions',
      'administer user form display',
      'administer users',
    ]);

    // Ensure relevant blocks present if profile isn't 'standard'.
    if ($this->profile !== 'standard') {
      $this
        ->drupalPlaceBlock('local_actions_block');
      $this
        ->drupalPlaceBlock('page_title_block');
    }
  }

  /**
   * {@inheritdoc}
   *
   * Ensures generated names are lower case.
   */
  protected function randomMachineName($length = 8) {
    return strtolower(parent::randomMachineName($length));
  }

  /**
   * Get an entity bypassing static and db cache.
   *
   * @param string $entity_type
   *   The type of entity to get.
   * @param string $entity_id
   *   The ID or name to load the entity using.
   *
   * @return EntityLegalDocument
   *   The retrieved entity.
   */
  public function getUncachedEntity($entity_type, $entity_id) {
    $controller = \Drupal::entityTypeManager()
      ->getStorage($entity_type);
    $controller
      ->resetCache([
      $entity_id,
    ]);
    return $controller
      ->load($entity_id);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityLegalTestBase::$adminUser protected property The administrative user to use for tests.
EntityLegalTestBase::$modules public static property Modules to enable.
EntityLegalTestBase::getUncachedEntity public function Get an entity bypassing static and db cache.
EntityLegalTestBase::randomMachineName protected function Ensures generated names are lower case.
EntityLegalTestBase::setUp protected function
EntityLegalTestTrait::createDocument protected function Creates a random legal document entity.
EntityLegalTestTrait::createDocumentVersion protected function Creates a document version.
EntityLegalTestTrait::createUserWithAcceptancePermissions protected function Creates an account that is able to view and re-accept a given document.