LogTestBase.php in Log entity 2.x
File
tests/src/Functional/LogTestBase.php
View source
<?php
namespace Drupal\Tests\log\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Tests\BrowserTestBase;
abstract class LogTestBase extends BrowserTestBase {
use StringTranslationTrait;
protected $defaultTheme = 'stark';
protected $storage;
public static $modules = [
'entity',
'user',
'log',
'log_test',
'field',
'text',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$entity_type_manager = $this->container
->get('entity_type.manager');
$this->storage = $entity_type_manager
->getStorage('log');
$this->adminUser = $this
->drupalCreateUser($this
->getAdministratorPermissions());
$this
->drupalLogin($this->adminUser);
drupal_flush_all_caches();
}
protected function getAdministratorPermissions() {
return [
'access administration pages',
'administer log',
'view any log',
'create default log',
'view any default log',
'update own default log',
'update any default log',
'delete own default log',
'delete any default log',
];
}
protected function createLogEntity(array $values = []) {
$entity = $this->storage
->create($values + [
'name' => $this
->randomMachineName(),
'created' => \Drupal::time()
->getRequestTime(),
'type' => 'default',
]);
return $entity;
}
}