You are here

protected function SchedulerHooksLegacyTest::createUnapprovedNode in Scheduler 2.x

Creates a new node that is not approved.

The node has a publish/unpublish date in the past to make sure it will be included in the next cron run.

Parameters

string $date_field: The Scheduler date field to set, either 'publish_on' or 'unpublish_on'.

Return value

\Drupal\node\NodeInterface A node object.

2 calls to SchedulerHooksLegacyTest::createUnapprovedNode()
SchedulerHooksLegacyTest::testAllowedPublishing in tests/src/Functional/SchedulerHooksLegacyTest.php
Covers hook_scheduler_allow_publishing()
SchedulerHooksLegacyTest::testAllowedUnpublishing in tests/src/Functional/SchedulerHooksLegacyTest.php
Covers hook_scheduler_allow_unpublishing()

File

tests/src/Functional/SchedulerHooksLegacyTest.php, line 295

Class

SchedulerHooksLegacyTest
Tests the legacy API hook functions of the Scheduler module.

Namespace

Drupal\Tests\scheduler\Functional

Code

protected function createUnapprovedNode($date_field) {
  $settings = [
    'title' => ($date_field == 'publish_on' ? 'Blue' : 'Red') . " legacy node {$this->randomMachineName(10)}",
    'status' => $date_field == 'unpublish_on',
    $date_field => strtotime('-1 day'),
    'field_approved_publishing' => 0,
    'field_approved_unpublishing' => 0,
    'type' => $this->customName,
  ];
  return $this
    ->drupalCreateNode($settings);
}