You are here

public function RulesDebugLogTest::testEventDebugLogMessage in Rules 8.3

Tests that entity CRUD events get fired only once.

File

tests/src/Functional/RulesDebugLogTest.php, line 49

Class

RulesDebugLogTest
Tests that the Rules UI pages are reachable.

Namespace

Drupal\Tests\rules\Functional

Code

public function testEventDebugLogMessage() {

  // Create a user who can see the rules debug logs.
  $account = $this
    ->createUser([
    'administer rules',
    'access rules debug',
    'create page content',
  ]);
  $this
    ->drupalLogin($account);

  // Create a Rule which we can trigger.
  $this
    ->drupalGet('admin/config/workflow/rules');
  $this
    ->clickLink('Add reaction rule');
  $this
    ->fillField('Label', 'Test rule');
  $this
    ->fillField('Machine-readable name', 'test_rule');
  $this
    ->fillField('React on event', 'rules_entity_insert:node');
  $this
    ->pressButton('Save');

  // Add a new page, which should trigger the above Rule.
  $this
    ->drupalGet('node/add/page');
  $this
    ->fillField('Title', 'Test page');
  $this
    ->pressButton('Save');

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();

  // Ensure that one and only one event message appears.
  $assert
    ->pageTextContainsOnce('0 ms Reacting on event After saving a new content item.');
}