You are here

function ContextReactionMenuTest::test in Context 6

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

File

tests/context.reactions.test, line 95

Class

ContextReactionMenuTest

Code

function test() {
  ctools_include('export');
  $context = ctools_export_new_object('context');
  $context->name = 'testcontext';
  $context->conditions = array(
    'sitewide' => array(
      'values' => array(
        1,
      ),
    ),
  );
  $context->reactions = array(
    'menu' => 'node/add',
  );
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalPost('admin/structure/menu/settings', array(
    'menu_main_links_source' => 'management',
  ), 'Save configuration');
  theme_enable(array(
    'bartik',
  ));
  variable_set('theme_default', 'bartik');
  $this
    ->refreshVariables();
  $output = $this
    ->drupalGet('user');
  $url = url('node/add');
  $active = $this
    ->xpath('//li[contains(@class, "active")]/a[@href="' . $url . '"]');
  $this
    ->assertTrue(!empty($active), t('Active menu item found.'));

  // Cleanup
  context_delete($context);
}