entity_legal-4.0.x-dev/tests/src/Functional/EntityLegalTestBase.php
tests/src/Functional/EntityLegalTestBase.php
<?php
declare(strict_types=1);
namespace Drupal\Tests\entity_legal\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\entity_legal\Traits\EntityLegalTestTrait;
/**
* Common Simpletest class for all legal tests.
*/
abstract class EntityLegalTestBase extends BrowserTestBase {
use EntityLegalTestTrait;
/**
* The administrative user to use for tests.
*
* @var \Drupal\user\Entity\User
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = ['block', 'entity_legal', 'field_ui', 'token'];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
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.
*
* @param int $length
* Length of random string to generate.
*
* @return string
* Randomly generated unique string.
*
* @see \Drupal\Component\Utility\Random::name()
*/
protected function randomMachineName($length = 8): string {
return strtolower(parent::randomMachineName($length));
}
}
