function AnnotationProcessingTest::testCheckConfiguration

Tests if our ContextDefinition annotations are correctly processed.

@dataProvider provideRulesPlugins

Parameters

string $plugin_type: Type of rules plugin to test (for now, 'action' or 'condition').

string $plugin_id: Plugin ID for the plugin to be tested.

string $context_name: The name of the plugin's context to test.

string $expected: The type of context as defined in the plugin's annotation.

File

tests/src/Unit/Integration/Engine/AnnotationProcessingTest.php, line 66

Class

AnnotationProcessingTest
Tests processing of the ContextDefinition annotation.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testCheckConfiguration($plugin_type, $plugin_id, $context_name, $expected) {
    $plugin = NULL;
    switch ($plugin_type) {
        case 'action':
            $plugin = $this->actionManager
                ->createInstance($plugin_id);
            break;
        case 'condition':
            $plugin = $this->conditionManager
                ->createInstance($plugin_id);
            break;
    }
    $this->assertNotNull($plugin, "{$plugin_type} plugin {$plugin_id} loads");
    $context = $plugin->getContext($context_name);
    $this->assertNotNull($context, "Plugin {$plugin_id} has context {$context_name}");
    $context_def = $context->getContextDefinition();
    $type = $context_def->getDataType();
    $this->assertSame($type, $expected, "Context type for {$context_name} is {$expected}");
}