You are here

public function RequestParamConditionTest::testEvaluate in Condition Query 8

@covers \Drupal\condition_query\Plugin\Condition\RequestParam::evaluate

@dataProvider provideEvaluate

Parameters

string $request_path: The request path to test with, including any query parameters.

string[] $config: Array of plugin configuration to use for the test case. Keys can be any supported configuration values that the plugin accepts ('request_param').

bool $expected: The expected return value from the evaluate() method.

File

tests/src/Kernel/RequestParamConditionTest.php, line 66

Class

RequestParamConditionTest
Tests that the Request Param Condition is working properly.

Namespace

Drupal\Tests\condition_query\Kernel

Code

public function testEvaluate(string $request_path, array $config, bool $expected) : void {

  /* @var \Drupal\condition_query\Plugin\Condition\RequestParam $condition */
  $condition = $this->pluginManager
    ->createInstance('request_param');
  foreach ($config as $key => $value) {
    $condition
      ->setConfig($key, $value);
  }
  $request = Request::create($request_path);
  $this->requestStack
    ->push($request);
  $this
    ->assertEquals($expected, $condition
    ->execute());
  $this->requestStack
    ->pop();
}