LegalTestBase.php in Legal 8
File
tests/src/Functional/LegalTestBase.php
View source
<?php
namespace Drupal\Tests\legal\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\legal\Entity\Conditions;
use Drupal\filter\Entity\FilterFormat;
abstract class LegalTestBase extends BrowserTestBase {
public static $modules = [
'legal',
'filter',
];
protected $account;
protected $loginDetails;
protected $uid;
protected $conditions;
protected $conditionsPlainText;
public function setUp() {
parent::setUp();
$this
->setOutputCallback(function () {
});
$full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
]);
$full_html_format
->save();
$this->account = $this
->drupalCreateUser([]);
$this
->drupalLogin($this->account);
$this->loginDetails['name'] = $this->account
->getAccountName();
$this->loginDetails['pass'] = $this->account->pass_raw;
$this->uid = $this->account
->id();
$this
->drupalLogout();
$language = 'en';
$version = legal_version('version', $language);
$this->conditions = '<div class="legal-html-text">Lorem ipsum.</div>';
$this->conditionsPlainText = 'Lorem ipsum.';
$extras = 'a:10:{s:8:"extras-1";s:0:"";s:8:"extras-2";s:0:"";s:8:"extras-3";s:0:"";s:8:"extras-4";s:0:"";s:8:"extras-5";s:0:"";s:8:"extras-6";s:0:"";s:8:"extras-7";s:0:"";s:8:"extras-8";s:0:"";s:8:"extras-9";s:0:"";s:9:"extras-10";s:0:"";}';
Conditions::create([
'version' => $version['version'],
'revision' => $version['revision'],
'language' => $language,
'conditions' => $this->conditions,
'format' => 'full_html',
'date' => time(),
'extras' => $extras,
'changes' => '',
])
->save();
}
}
Classes
Name |
Description |
LegalTestBase |
Provides setup and helper methods for Legal module tests. |