You are here

function MobileToolsContextConditionMobileTest::testContext in Mobile Tools 7.3

Creates a Context using the default device group and tests whether that context is active when viewing the URL for that device group.

File

mobile_tools_context/mobile_tools_context.test, line 41
Tests for mobile_tools_context

Class

MobileToolsContextConditionMobileTest
@file Tests for mobile_tools_context

Code

function testContext() {
  ctools_include('export');

  // Create a context for this device group
  $context = ctools_export_new_object('context');
  $context->name = 'mt7_test';
  $context->tag = 'development';
  $context->conditions = array(
    'device_group' => array(
      'values' => array(
        'mobile' => 'mobile',
      ),
    ),
  );
  $context->reactions = array(
    'debug' => array(
      'debug' => TRUE,
    ),
  );
  $context->disabled = FALSE;
  $context->api_version = 3;
  $context->description = '';
  $context->reactions = array(
    'debug' => array(
      'debug' => 1,
    ),
  );
  $context->condition_mode = 0;
  $saved = context_save($context);
  $this
    ->assertTrue($saved, "Context 'mt7_test' saved.");

  // With the debug mode on, Context will print to screen when the context is
  // active
  $this
    ->drupalGet('mobile');
  $this
    ->assertText('Active context: mt7_test');

  // Configure the mobile tools settings to not trigger the mobile context
  // @todo
  // @todo repeat tests from above
  // Cleanup
  context_delete($context);

  // @todo: Test with language suffixes
}