class RulesUnitTestBase

Helper class with mock objects.

Hierarchy

Expanded class hierarchy of RulesUnitTestBase

1 file declares its use of RulesUnitTestBase
ReactionRuleConfigTest.php in tests/src/Unit/Entity/ReactionRuleConfigTest.php

File

tests/src/Unit/RulesUnitTestBase.php, line 16

Namespace

Drupal\Tests\rules\Unit
View source
abstract class RulesUnitTestBase extends UnitTestCase {
  
  /**
   * A mocked condition that always evaluates to TRUE.
   *
   * @var \Drupal\rules\Engine\ConditionExpressionInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $trueConditionExpression;
  
  /**
   * A mocked condition that always evaluates to FALSE.
   *
   * @var \Drupal\rules\Engine\ConditionExpressionInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $falseConditionExpression;
  
  /**
   * A mocked dummy action object.
   *
   * @var \Drupal\rules\Engine\ActionExpressionInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $testActionExpression;
  
  /**
   * A mocked dummy action object.
   *
   * @var \Drupal\rules\Engine\ActionExpressionInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $testFirstActionExpression;
  
  /**
   * The mocked expression manager object.
   *
   * @var \Drupal\rules\Engine\ExpressionPluginManager|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $expressionManager;
  
  /**
   * The mocked expression manager object.
   *
   * @var \Drupal\rules\src\Logger\|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $rulesDebugLogger;
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    // A Condition that's always TRUE.
    $this->trueConditionExpression = $this->prophesize(ConditionExpressionInterface::class);
    $this->trueConditionExpression
      ->getUuid()
      ->willReturn('true_uuid1');
    $this->trueConditionExpression
      ->getWeight()
      ->willReturn(0);
    $this->trueConditionExpression
      ->execute()
      ->willReturn(TRUE);
    $this->trueConditionExpression
      ->executeWithState(Argument::type(ExecutionStateInterface::class))
      ->willReturn(TRUE);
    // A Condition that's always FALSE.
    $this->falseConditionExpression = $this->prophesize(ConditionExpressionInterface::class);
    $this->falseConditionExpression
      ->getUuid()
      ->willReturn('false_uuid1');
    $this->falseConditionExpression
      ->getWeight()
      ->willReturn(0);
    $this->falseConditionExpression
      ->execute()
      ->willReturn(FALSE);
    $this->falseConditionExpression
      ->executeWithState(Argument::type(ExecutionStateInterface::class))
      ->willReturn(FALSE);
    // An Action with a low weight.
    $this->testFirstActionExpression = $this->prophesize(ActionExpressionInterface::class);
    $this->testFirstActionExpression
      ->getUuid()
      ->willReturn('action_uuid0');
    $this->testFirstActionExpression
      ->getWeight()
      ->willReturn(-1);
    // An Action with a heavier weight.
    $this->testActionExpression = $this->prophesize(ActionExpressionInterface::class);
    $this->testActionExpression
      ->getUuid()
      ->willReturn('action_uuid1');
    $this->testActionExpression
      ->getWeight()
      ->willReturn(0);
    $this->expressionManager = $this->prophesize(ExpressionManagerInterface::class);
    $this->rulesDebugLogger = $this->prophesize(LoggerChannelInterface::class);
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
RulesUnitTestBase::$expressionManager protected property The mocked expression manager object. 1
RulesUnitTestBase::$falseConditionExpression protected property A mocked condition that always evaluates to FALSE.
RulesUnitTestBase::$rulesDebugLogger protected property The mocked expression manager object.
RulesUnitTestBase::$testActionExpression protected property A mocked dummy action object.
RulesUnitTestBase::$testFirstActionExpression protected property A mocked dummy action object.
RulesUnitTestBase::$trueConditionExpression protected property A mocked condition that always evaluates to TRUE.
RulesUnitTestBase::setUp protected function Overrides UnitTestCase::setUp 4
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function