You are here

protected function SchedulerHooksTest::createUnapprovedEntity in Scheduler 2.x

Creates a new entity that is not approved.

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

Parameters

string $entityTypeId: The entity type to create, 'node' or 'media'.

string $bundle: The bundle to create, 'scheduler_api_test' or 'scheduler_api_media_test'.

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

Return value

\Drupal\Core\Entity\EntityInterface The created entity object.

2 calls to SchedulerHooksTest::createUnapprovedEntity()
SchedulerHooksTest::testPublishingAllowed in tests/src/Functional/SchedulerHooksTest.php
Covers hook_scheduler_{type}_publishing_allowed()
SchedulerHooksTest::testUnpublishingAllowed in tests/src/Functional/SchedulerHooksTest.php
Covers hook_scheduler_{type}_unpublishing_allowed()

File

tests/src/Functional/SchedulerHooksTest.php, line 383

Class

SchedulerHooksTest
Tests the API hook functions of the Scheduler module.

Namespace

Drupal\Tests\scheduler\Functional

Code

protected function createUnapprovedEntity($entityTypeId, $bundle, $date_field) {
  $settings = [
    'title' => ($date_field == 'publish_on' ? 'Blue' : 'Red') . " {$entityTypeId} {$this->randomMachineName(10)}",
    'status' => $date_field == 'unpublish_on',
    $date_field => strtotime('-1 day'),
    'field_approved_publishing' => 0,
    'field_approved_unpublishing' => 0,
  ];
  return $this
    ->createEntity($entityTypeId, $bundle, $settings);
}