function ConfigEntityDefaultsTest::testDefaultComponents

Tests Rules default components.

File

tests/src/Kernel/ConfigEntityDefaultsTest.php, line 57

Class

ConfigEntityDefaultsTest
Tests default config.

Namespace

Drupal\Tests\rules\Kernel

Code

public function testDefaultComponents() {
    $config_entity = $this->storage
        ->load('rules_test_default_component');
    $user = $this->entityTypeManager
        ->getStorage('user')
        ->create([
        'mail' => 'test@example.com',
    ]);
    $result = $config_entity->getComponent()
        ->setContextValue('user', $user)
        ->execute();
    // Test that the action was executed correctly.
    $messages = $this->container
        ->get('messenger')
        ->all();
    $message_string = isset($messages['status'][0]) ? (string) $messages['status'][0] : NULL;
    $this->assertEquals($message_string, 'test@example.com');
    $this->assertEquals('test@example.comtest@example.com', $result['concatenated']);
}