You are here

public function SchedulerRulesEventsTest::testRulesEventsNone in Scheduler 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/SchedulerRulesEventsTest.php \Drupal\Tests\scheduler\Functional\SchedulerRulesEventsTest::testRulesEventsNone()

Tests that no events are triggered when there are no scheduling dates.

File

tests/src/Functional/SchedulerRulesEventsTest.php, line 72

Class

SchedulerRulesEventsTest
Tests the six events that Scheduler provides for use in Rules module.

Namespace

Drupal\Tests\scheduler\Functional

Code

public function testRulesEventsNone() {
  $assert = $this
    ->assertSession();

  // Create a node without any scheduled dates, using node/add/ not
  // drupalCreateNode(), and check that no events are triggered.
  $edit = [
    'title[0][value]' => 'Test for no events',
    'body[0][value]' => $this
      ->randomString(30),
  ];
  $this
    ->drupalPostForm('node/add/' . $this->type, $edit, 'Save');
  $node = $this
    ->drupalGetNodeByTitle($edit['title[0][value]']);
  $assert
    ->pageTextNotContains($this->message[1]);
  $assert
    ->pageTextNotContains($this->message[2]);
  $assert
    ->pageTextNotContains($this->message[3]);
  $assert
    ->pageTextNotContains($this->message[4]);
  $assert
    ->pageTextNotContains($this->message[5]);
  $assert
    ->pageTextNotContains($this->message[6]);

  // Edit the node and check that no events are triggered.
  $edit = [
    'body[0][value]' => $this
      ->randomString(30),
  ];
  $this
    ->drupalPostForm('node/' . $node
    ->id() . '/edit', $edit, 'Save');
  $assert
    ->pageTextNotContains($this->message[1]);
  $assert
    ->pageTextNotContains($this->message[2]);
  $assert
    ->pageTextNotContains($this->message[3]);
  $assert
    ->pageTextNotContains($this->message[4]);
  $assert
    ->pageTextNotContains($this->message[5]);
  $assert
    ->pageTextNotContains($this->message[6]);
}