function ConfigActionsTest::testConfigActions

Same name in this branch
  1. 11.x core/modules/media/tests/src/Kernel/ConfigActionsTest.php \Drupal\Tests\media\Kernel\ConfigActionsTest::testConfigActions()
  2. 11.x core/modules/language/tests/src/Kernel/ConfigActionsTest.php \Drupal\Tests\language\Kernel\ConfigActionsTest::testConfigActions()
  3. 11.x core/modules/field/tests/src/Kernel/ConfigActionsTest.php \Drupal\Tests\field\Kernel\ConfigActionsTest::testConfigActions()
  4. 11.x core/modules/node/tests/src/Kernel/ConfigActionsTest.php \Drupal\Tests\node\Kernel\ConfigActionsTest::testConfigActions()
  5. 11.x core/modules/image/tests/src/Kernel/ConfigActionsTest.php \Drupal\Tests\image\Kernel\ConfigActionsTest::testConfigActions()

File

core/modules/contact/tests/src/Kernel/ConfigActionsTest.php, line 32

Class

ConfigActionsTest
@group contact

Namespace

Drupal\Tests\contact\Kernel

Code

public function testConfigActions() : void {
    $form = ContactForm::load('personal');
    $this->assertSame('Your message has been sent.', $form->getMessage());
    $this->assertEmpty($form->getRecipients());
    $this->assertSame('/', $form->getRedirectUrl()
        ->toString());
    $this->assertEmpty($form->getReply());
    $this->assertSame(0, $form->getWeight());
    $this->configActionManager
        ->applyAction('entity_method:contact.form:setMessage', $form->getConfigDependencyName(), 'Fly, little message!');
    $this->configActionManager
        ->applyAction('entity_method:contact.form:setRecipients', $form->getConfigDependencyName(), [
        'ben@deep.space',
        'jake@deep.space',
    ]);
    $this->configActionManager
        ->applyAction('entity_method:contact.form:setRedirectPath', $form->getConfigDependencyName(), '/admin/appearance');
    $this->configActionManager
        ->applyAction('entity_method:contact.form:setReply', $form->getConfigDependencyName(), "From hell's heart, I reply to thee.");
    $this->configActionManager
        ->applyAction('entity_method:contact.form:setWeight', $form->getConfigDependencyName(), -10);
    $form = ContactForm::load($form->id());
    $this->assertSame('Fly, little message!', $form->getMessage());
    $this->assertSame([
        'ben@deep.space',
        'jake@deep.space',
    ], $form->getRecipients());
    $this->assertSame('/admin/appearance', $form->getRedirectUrl()
        ->toString());
    $this->assertSame("From hell's heart, I reply to thee.", $form->getReply());
    $this->assertSame(-10, $form->getWeight());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.