UiPageTest.php in Rules 8.3
File
tests/src/Functional/UiPageTest.php
View source
<?php
namespace Drupal\Tests\rules\Functional;
class UiPageTest extends RulesBrowserTestBase {
protected static $modules = [
'rules',
'rules_test',
];
protected $profile = 'minimal';
public function testReactionRulePage() {
$account = $this
->drupalCreateUser([
'administer rules',
]);
$this
->drupalLogin($account);
$this
->drupalGet('admin/config/workflow/rules');
$assert = $this
->assertSession();
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('There are no enabled reaction rules.');
}
public function testCreateReactionRule() {
$account = $this
->drupalCreateUser([
'administer rules',
]);
$this
->drupalLogin($account);
$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');
$assert = $this
->assertSession();
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('Reaction rule Test rule has been created.');
$this
->clickLink('Add condition');
$this
->fillField('Condition', 'rules_node_is_promoted');
$this
->pressButton('Continue');
$this
->fillField('context_definitions[node][setting]', 'node');
$this
->pressButton('Save');
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('You have unsaved changes.');
$this
->pressButton('Save');
$assert
->pageTextContains('Reaction rule Test rule has been updated. ');
}
public function testRuleStatusOperations() {
$this
->testCreateReactionRule();
$this
->drupalGet('admin/config/workflow/rules');
$assert = $this
->assertSession();
$this
->clickLink('Disable');
$assert
->pageTextContains('The reaction rule Test rule has been disabled.');
$this
->clickLink('Enable');
$assert
->pageTextContains('The reaction rule Test rule has been enabled.');
}
public function testCancelExpressionInRule() {
$this
->testCreateReactionRule();
$this
->clickLink('Add condition');
$this
->fillField('Condition', 'rules_node_is_promoted');
$this
->pressButton('Continue');
$this
->fillField('context_definitions[node][setting]', 'node');
$this
->pressButton('Save');
$assert = $this
->assertSession();
$assert
->pageTextContains('You have unsaved changes.');
$this
->pressButton('Cancel');
$assert
->pageTextContains('Canceled.');
$this
->assertEquals(1, preg_match('#/admin/config/workflow/rules$#', $this
->getSession()
->getCurrentUrl()));
}
public function testDeleteExpressionInRule() {
$this
->testCreateReactionRule();
$assert = $this
->assertSession();
$this
->clickLink('Delete');
$assert
->pageTextContains('Are you sure you want to delete Node is promoted from Test rule?');
$this
->pressButton('Delete');
$assert
->pageTextContains('You have unsaved changes.');
$this
->pressButton('Save');
$assert
->pageTextContains('Reaction rule Test rule has been updated. ');
}
public function testNoContextCondition() {
$this
->testCreateReactionRule();
$this
->clickLink('Add condition');
$this
->fillField('Condition', 'rules_test_true');
$this
->pressButton('Continue');
$this
->pressButton('Save');
}
public function testNegatedCondition() {
$this
->testCreateReactionRule();
$assert = $this
->assertSession();
$assert
->pageTextContains('Node is promoted');
$this
->clickLink('Edit');
$this
->fillField('Negate', 1);
$this
->pressButton('Save');
$assert
->pageTextContains('NOT Node is promoted');
}
public function testMultipleContextAction() {
$account = $this
->drupalCreateUser([
'administer rules',
]);
$this
->drupalLogin($account);
$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');
$this
->clickLink('Add action');
$this
->fillField('Action', 'rules_send_email');
$this
->pressButton('Continue');
$this
->pressButton('Switch to data selection');
$this
->pressButton('Switch to the direct input mode');
$this
->fillField('context_definitions[to][setting]', 'klausi@example.com');
$this
->fillField('context_definitions[subject][setting]', 'subject');
$this
->fillField('context_definitions[message][setting]', 'message');
$this
->pressButton('Save');
$assert = $this
->assertSession();
$assert
->statusCodeEquals(200);
}
}
Classes
Name |
Description |
UiPageTest |
Tests that the Rules UI pages are reachable. |