You are here

function ContextConditionUserPageTest::test in Context 7.3

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

File

tests/context.conditions.test, line 116

Class

ContextConditionUserPageTest

Code

function test() {

  // Viewing any user profile triggers context.
  $this
    ->drupalLogin($this->user1);
  $this
    ->drupalGet("user/{$this->user1->uid}");
  $this
    ->assertText('Active context: testcontext');
  $this
    ->drupalGet("user/{$this->user2->uid}");
  $this
    ->assertText('Active context: testcontext');

  // User form does not.
  $this
    ->drupalGet("user/{$this->user1->uid}/edit");
  $this
    ->assertNoText('Active context: testcontext');

  // Test current user mode
  $this->context->conditions['user_page']['options']['mode'] = 'current';
  $saved = context_save($this->context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalGet("user/{$this->user1->uid}");
  $this
    ->assertText('Active context: testcontext');
  $this
    ->drupalGet("user/{$this->user2->uid}");
  $this
    ->assertNoText('Active context: testcontext');

  // Test other user mode
  $this->context->conditions['user_page']['options']['mode'] = 'other';
  $saved = context_save($this->context);
  $this
    ->assertTrue($saved, "Context 'testcontext' saved.");
  $this
    ->drupalGet("user/{$this->user1->uid}");
  $this
    ->assertNoText('Active context: testcontext');
  $this
    ->drupalGet("user/{$this->user2->uid}");
  $this
    ->assertText('Active context: testcontext');
}