You are here

function ContextConditionNodeTest::test in Context 6

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

File

tests/context.conditions.test, line 371

Class

ContextConditionNodeTest

Code

function test() {
  ctools_include('export');
  $context = ctools_export_new_object('context');
  $context->name = 'testcontext';
  $context->conditions = array(
    'node' => array(
      'values' => array(
        'blog',
      ),
    ),
  );
  $context->reactions = array(
    'debug' => array(
      'debug' => TRUE,
    ),
  );
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalGet("node/add/blog");
  $this
    ->assertNoText('Active context: testcontext');
  $this
    ->drupalGet("node/add/book");
  $this
    ->assertNoText('Active context: testcontext');
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'blog',
  ));
  $this
    ->drupalGet("node/{$node->nid}");
  $this
    ->assertText('Active context: testcontext');
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'book',
  ));
  $this
    ->drupalGet("node/{$node->nid}");
  $this
    ->assertNoText('Active context: testcontext');
  $context->conditions['node']['options']['node_form'] = 1;
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalGet("node/add/blog");
  $this
    ->assertText('Active context: testcontext');
  $this
    ->drupalGet("node/add/book");
  $this
    ->assertNoText('Active context: testcontext');

  // Cleanup
  context_delete($context);
}