abstract class EntityLegalTestBase in Entity Legal 3.0.x
Same name and namespace in other branches
- 8.2 src/Tests/EntityLegalTestBase.php \Drupal\entity_legal\Tests\EntityLegalTestBase
- 4.0.x src/Tests/EntityLegalTestBase.php \Drupal\entity_legal\Tests\EntityLegalTestBase
Common Simpletest class for all legal tests.
Hierarchy
- class \Drupal\entity_legal\Tests\EntityLegalTestBase extends \Drupal\simpletest\WebTestBase uses EntityLegalTestTrait
Expanded class hierarchy of EntityLegalTestBase
File
- src/
Tests/ EntityLegalTestBase.php, line 11
Namespace
Drupal\entity_legal\TestsView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityLegalTestBase:: |
protected | property | The administrative user to use for tests. | |
EntityLegalTestBase:: |
public static | property | Modules to enable. | |
EntityLegalTestBase:: |
public | function | Get an entity bypassing static and db cache. | |
EntityLegalTestBase:: |
protected | function | Ensures generated names are lower case. | |
EntityLegalTestBase:: |
protected | function | ||
EntityLegalTestTrait:: |
protected | function | Creates a random legal document entity. | |
EntityLegalTestTrait:: |
protected | function | Creates a document version. | |
EntityLegalTestTrait:: |
protected | function | Creates an account that is able to view and re-accept a given document. |