You are here

protected function SchedulerHooksLegacyTest::approveNode in Scheduler 2.x

Approves a node for publication or unpublication.

Parameters

int $nid: The id of the node to approve.

string $field_name: The name of the field to set, either 'field_approved_publishing' or 'field_approved_unpublishing'.

2 calls to SchedulerHooksLegacyTest::approveNode()
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 316

Class

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

Namespace

Drupal\Tests\scheduler\Functional

Code

protected function approveNode($nid, $field_name) {
  $this->nodeStorage
    ->resetCache([
    $nid,
  ]);
  $node = $this->nodeStorage
    ->load($nid);
  $node
    ->set($field_name, TRUE);
  $node
    ->set('title', $node
    ->label() . " - approved for publishing: {$node->field_approved_publishing->value}, for unpublishing: {$node->field_approved_unpublishing->value}")
    ->save();
}