public function SchedulerSetupTrait::schedulerSetUp in Scheduler 8
Same name and namespace in other branches
- 2.x tests/src/Traits/SchedulerSetupTrait.php \Drupal\Tests\scheduler\Traits\SchedulerSetupTrait::schedulerSetUp()
Set common properties, define content types and create users.
2 calls to SchedulerSetupTrait::schedulerSetUp()
- SchedulerBrowserTestBase::setUp in tests/
src/ Functional/ SchedulerBrowserTestBase.php - SchedulerJavascriptTestBase::setUp in tests/
src/ FunctionalJavascript/ SchedulerJavascriptTestBase.php
File
- tests/
src/ Traits/ SchedulerSetupTrait.php, line 93
Class
- SchedulerSetupTrait
- Generic setup for all Scheduler tests.
Namespace
Drupal\Tests\scheduler\TraitsCode
public function schedulerSetUp() {
// Create a test content type with id 'testpage' and name 'Test Page'.
// The tests should use $this->type and $this->typeName and not use
// $this->nodetype->get('type') or $this->nodetype->get('name'), nor have
// the hard-coded strings 'testpage' or 'Test Page'.
$this->type = 'testpage';
$this->typeName = 'Test Page';
/** @var NodeTypeInterface $nodetype */
$this->nodetype = $this
->drupalCreateContentType([
'type' => $this->type,
'name' => $this->typeName,
]);
// Add scheduler functionality to the content type.
$this->nodetype
->setThirdPartySetting('scheduler', 'publish_enable', TRUE)
->setThirdPartySetting('scheduler', 'unpublish_enable', TRUE)
->save();
// The majority of tests use the standard Scheduler-enabled content type but
// we also need a content type which is not enabled for Scheduler.
$this->nonSchedulerNodeType = $this
->drupalCreateContentType([
'type' => 'not-for-scheduler',
'name' => 'Not For Scheduler',
]);
// Define nodeStorage for use in many tests.
/** @var EntityStorageInterface $nodeStorage */
$this->nodeStorage = $this->container
->get('entity_type.manager')
->getStorage('node');
// Create an administrator user having the main admin permissions, full
// rights on the test content type and all of the Scheduler permissions.
// 'access site reports' is required for admin/reports/dblog.
// 'administer site configuration' is required for admin/reports/status.
$this->adminUser = $this
->drupalCreateUser([
'access content',
'access content overview',
'access site reports',
'administer nodes',
'administer site configuration',
'create ' . $this->type . ' content',
'edit any ' . $this->type . ' content',
'delete any ' . $this->type . ' content',
'create ' . $this->nonSchedulerNodeType
->id() . ' content',
'edit any ' . $this->nonSchedulerNodeType
->id() . ' content',
'delete any ' . $this->nonSchedulerNodeType
->id() . ' content',
'view own unpublished content',
'administer scheduler',
'schedule publishing of nodes',
'view scheduled content',
]);
// Create an ordinary Scheduler user, with permission to create and schedule
// content but not with administrator permissions.
$this->schedulerUser = $this
->drupalCreateUser([
'create ' . $this->type . ' content',
'edit own ' . $this->type . ' content',
'delete own ' . $this->type . ' content',
'view own unpublished content',
'schedule publishing of nodes',
'view scheduled content',
]);
// Store the database connection for re-use in the actual tests.
$this->database = $this->container
->get('database');
// Determine the request time and save for re-use in the actual tests.
$this->requestTime = $this->container
->get('datetime.time')
->getRequestTime();
// Store the core dateFormatter service for re-use in the actual tests.
$this->dateFormatter = $this->container
->get('date.formatter');
}