AssetTestBase.php in farmOS 2.x
File
modules/core/asset/tests/src/Functional/AssetTestBase.php
View source
<?php
namespace Drupal\Tests\asset\Functional;
use Drupal\Tests\farm_test\Functional\FarmBrowserTestBase;
abstract class AssetTestBase extends FarmBrowserTestBase {
protected static $modules = [
'asset',
'asset_test',
'entity',
'user',
'field',
'text',
];
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser($this
->getAdministratorPermissions());
$this
->drupalLogin($this->adminUser);
drupal_flush_all_caches();
}
protected function getAdministratorPermissions() {
return [
'access administration pages',
'administer assets',
'view any asset',
'create default asset',
'view any default asset',
'update own default asset',
'update any default asset',
'delete own default asset',
'delete any default asset',
];
}
protected function createAssetEntity(array $values = []) {
$storage = \Drupal::service('entity_type.manager')
->getStorage('asset');
$entity = $storage
->create($values + [
'name' => $this
->randomMachineName(),
'created' => \Drupal::time()
->getRequestTime(),
'type' => 'default',
]);
return $entity;
}
}