function RulesComponentListBuilderTest::testCreateRulesComponent

Tests that creating a rules component works.

4 calls to RulesComponentListBuilderTest::testCreateRulesComponent()
RulesComponentListBuilderTest::testCancelExpressionInComponent in tests/src/Functional/RulesComponentListBuilderTest.php
Tests that cancelling an expression from a component works.
RulesComponentListBuilderTest::testDeleteExpressionInComponent in tests/src/Functional/RulesComponentListBuilderTest.php
Tests that deleting an expression from a rule works.
RulesComponentListBuilderTest::testNegatedCondition in tests/src/Functional/RulesComponentListBuilderTest.php
Tests that a negated condition has NOT prefixed to its label.
RulesComponentListBuilderTest::testNoContextCondition in tests/src/Functional/RulesComponentListBuilderTest.php
Tests that a condition with no context can be configured.

File

tests/src/Functional/RulesComponentListBuilderTest.php, line 66

Class

RulesComponentListBuilderTest
Tests that the Rules Component list builder pages work.

Namespace

Drupal\Tests\rules\Functional

Code

public function testCreateRulesComponent() {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/config/workflow/rules/components');
    $this->clickLink('Add component');
    $this->fillField('Label', 'Test component');
    $this->fillField('Machine-readable name', 'test_component');
    $this->fillField('Description', 'This is a test description for a test component.');
    $this->pressButton('Save');
    
    /** @var \Drupal\Tests\WebAssert $assert */
    $assert = $this->assertSession();
    $assert->statusCodeEquals(200);
    $assert->pageTextContains('Component Test component has been created.');
    $this->clickLink('Add condition');
    $this->fillField('Condition', 'rules_user_is_blocked');
    $this->pressButton('Continue');
    $this->fillField('context_definitions[user][setting]', '@user:current_user_context:current_user');
    $this->pressButton('Save');
    $assert->statusCodeEquals(200);
    $assert->pageTextContains('You have unsaved changes.');
    $this->pressButton('Save');
    $assert->pageTextContains('Rule component Test component has been updated. ');
}