PlanTestBase.php in farmOS 2.x
File
modules/core/plan/tests/src/Functional/PlanTestBase.php
View source
<?php
namespace Drupal\Tests\plan\Functional;
use Drupal\Tests\farm_test\Functional\FarmBrowserTestBase;
abstract class PlanTestBase extends FarmBrowserTestBase {
protected static $modules = [
'plan',
'plan_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 plans',
'view any plan',
'create default plan',
'view any default plan',
'update own default plan',
'update any default plan',
'delete own default plan',
'delete any default plan',
];
}
protected function createPlanEntity(array $values = []) {
$storage = \Drupal::service('entity_type.manager')
->getStorage('plan');
$entity = $storage
->create($values + [
'name' => $this
->randomMachineName(),
'created' => \Drupal::time()
->getRequestTime(),
'type' => 'default',
]);
return $entity;
}
}