DataSetTest.php in Rules 8.3
File
tests/src/Unit/Integration/RulesAction/DataSetTest.php
View source
<?php
namespace Drupal\Tests\rules\Unit\Integration\RulesAction;
use Drupal\Tests\rules\Unit\Integration\RulesIntegrationTestBase;
class DataSetTest extends RulesIntegrationTestBase {
protected $action;
protected function setUp() : void {
parent::setUp();
$this->action = $this->actionManager
->createInstance('rules_data_set');
}
public function testSummary() {
$this
->assertEquals('Set a data value', $this->action
->summary());
}
public function testPrimitiveValues() {
$this->action
->setContextValue('data', 'original')
->setContextValue('value', 'replacement');
$this->action
->execute();
$this
->assertSame('replacement', $this->action
->getContextValue('data'));
$this
->assertSame([], $this->action
->autoSaveContext());
}
public function testSetToNull() {
$this->action
->setContextValue('data', 'original');
$this->action
->execute();
$this
->assertNull($this->action
->getContextValue('data'));
$this
->assertSame([], $this->action
->autoSaveContext());
}
}