You are here

public function DataCalculateValueTest::testMinimumAction in Rules 8.3

Tests the use of min operator for 2 input values.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/DataCalculateValueTest.php, line 106

Class

DataCalculateValueTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\DataCalculateValue @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testMinimumAction() {
  $input_1 = mt_rand();
  $input_2 = mt_rand();
  $this->action
    ->setContextValue('input_1', $this
    ->getTypedData('float', $input_1))
    ->setContextValue('operator', $this
    ->getTypedData('string', 'min'))
    ->setContextValue('input_2', $this
    ->getTypedData('float', $input_2));
  $this->action
    ->execute();
  $result = $this->action
    ->getProvidedContext('result')
    ->getContextValue();
  $this
    ->assertEquals(min($input_1, $input_2), $result, "Min calculation correct");
}