You are here

public function SchedulerRulesEventsTest::testRulesEventsNone in Scheduler 2.x

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

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

@dataProvider dataStandardEntityTypes()

File

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

Class

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

Namespace

Drupal\Tests\scheduler\Functional

Code

public function testRulesEventsNone($entityTypeId, $bundle) {

  // Add and save an entity without any scheduled dates and check that no
  // events are triggered.
  $titleField = $entityTypeId == 'media' ? 'name' : 'title';
  $title = 'A. Create with no dates';
  $this
    ->drupalGet($this
    ->entityAddUrl($entityTypeId, $bundle));
  $this
    ->submitForm([
    "{$titleField}[0][value]" => $title,
  ], 'Save');
  $this
    ->checkMessages();

  // Edit the entity and check that no events are triggered.
  $entity = $this
    ->getEntityByTitle($entityTypeId, $title);
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $this
    ->submitForm([
    "{$titleField}[0][value]" => 'B. Edit with no dates',
  ], 'Save');
  $this
    ->checkMessages();
}