You are here

protected function ContextConditionContextEntityFieldTest::contextCreate in Context entity field 7

Helper method to create contexts.

Parameters

string $name: Machine name of context to create.

array $options: Settings (condiction) to create context.

3 calls to ContextConditionContextEntityFieldTest::contextCreate()
ContextConditionContextEntityNoFieldTest::createContexts in tests/context_entity_field.test
Create context to test conditions.
ContextConditionContextEntityTaxonomyFieldTest::createContexts in tests/context_entity_field.test
Create context to test conditions.
ContextConditionContextEntityTextFieldTest::createContexts in tests/context_entity_field.test
Create context to test conditions.

File

tests/context_entity_field.test, line 30
Test context condition.

Class

ContextConditionContextEntityFieldTest
Basic test definition.

Code

protected function contextCreate($name, $options) {
  $entities = array();
  foreach ($options['entity_type'] as $entity_type) {
    $entities[$entity_type] = $entity_type;
  }
  $options['entity_type'] = serialize($entities);
  $condictions = array(
    'entity_field' => array(
      'values' => array(
        'entity_type' => $options['entity_type'],
        'field_name' => $options['field_name'],
        'field_status' => $options['field_status'],
        'field_value' => $options['field_value'],
      ),
    ),
  );
  ctools_include('export');
  $context = ctools_export_new_object('context');
  $context->name = $name;
  $context->conditions = $condictions;
  $context->reactions = array(
    'debug' => array(
      'debug' => TRUE,
    ),
  );
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context '{$name}' saved.");
}