You are here

function ContextConditionPathTest::test in Context 6

Same name and namespace in other branches
  1. 6.3 tests/context.conditions.test \ContextConditionPathTest::test()
  2. 7.3 tests/context.conditions.test \ContextConditionPathTest::test()

File

tests/context.conditions.test, line 278

Class

ContextConditionPathTest

Code

function test() {
  ctools_include('export');
  $context = ctools_export_new_object('context');
  $context->name = 'testcontext';
  $context->conditions = array(
    'path' => array(
      'values' => array(
        'admin',
        'node/*',
      ),
    ),
  );
  $context->reactions = array(
    'debug' => array(
      'debug' => TRUE,
    ),
  );
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalGet('admin');
  $this
    ->assertText('Active context: testcontext');
  $node = $this
    ->drupalCreateNode();
  $this
    ->drupalGet("node/{$node->nid}");
  $this
    ->assertText('Active context: testcontext');
  $this
    ->drupalGet('node');
  $this
    ->assertNoText('Active context: testcontext');

  // Cleanup
  context_delete($context);

  // @TODO: Test with path alias
  // @TODO: Test with language prefixes
}