class ContextConditionContextTest

  1. nittany7 modules/contrib/context/tests/context.conditions.test ContextConditionContextTest
  2. cis7 modules/contrib/context/tests/context.conditions.test ContextConditionContextTest
  3. mooc7 modules/contrib/context/tests/context.conditions.test ContextConditionContextTest

Hierarchy

Expanded class hierarchy of ContextConditionContextTest

Members

Contains filters are case sensitive

File

modules/contrib/context/tests/context.conditions.test, line 309

View source
class ContextConditionContextTest extends DrupalWebTestCase {
  protected $profile = 'testing';

  public static function getInfo() {
    return array(
      'name' => 'Condition: context',
      'description' => 'Test context condition.',
      'group' => 'Context',
    );
  }

  function setUp() {
    parent::setUp('context', 'ctools');
    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer nodes'));
    $this->drupalLogin($admin_user);
  }

  function test() {
    ctools_include('export');
    $context = ctools_export_new_object('context');
    $context->name = 'testcontext';
    $context->conditions = array('path' => array('values' => array('admin')));
    $context->reactions = array('debug' => array('debug' => TRUE));
    $saved = context_save($context);
    $this->assertTrue($saved, "Context 'testcontext' saved.");

    $subcontext = ctools_export_new_object('context');
    $subcontext->name = 'subcontext';
    $subcontext->conditions = array('context' => array('values' => array('testcontext')));
    $subcontext->reactions = array('debug' => array('debug' => TRUE));
    $saved = context_save($subcontext);
    $this->assertTrue($saved, "Context 'subcontext' saved.");

    $this->drupalGet('admin');
    $this->assertText('Active context: testcontext');
    $this->assertText('Active context: subcontext');

    // Cleanup
    context_delete($context);

    // @TODO: Test exclusion
  }
}