public function SystemMessageTest::testActionExecution in Rules 8.3
Tests the action execution.
@covers ::execute
File
- tests/
src/ Unit/ Integration/ RulesAction/ SystemMessageTest.php, line 47
Class
- SystemMessageTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesAction\SystemMessage @group RulesAction
Namespace
Drupal\Tests\rules\Unit\Integration\RulesActionCode
public function testActionExecution() {
$this->action
->setContextValue('message', 'test message')
->setContextValue('type', MessengerInterface::TYPE_STATUS)
->setContextValue('repeat', FALSE);
// Execute the action multiple times. The message should still only
// be stored once (repeat is set to FALSE).
$this->action
->execute();
$this->action
->execute();
$this->action
->execute();
$messages = $this
->getMessages(MessengerInterface::TYPE_STATUS);
$this
->assertNotNull($messages);
$this
->assertEquals([
'test message',
], $messages);
// Set the 'repeat' context to TRUE and execute the action again.
$this->action
->setContextValue('repeat', TRUE);
$this->action
->execute();
// The message should be repeated now.
$messages = $this
->getMessages(MessengerInterface::TYPE_STATUS);
$this
->assertNotNull($messages);
$this
->assertEquals([
'test message',
'test message',
], $messages);
}