You are here

RequiredByRoleCallbackAlterTestCase.test in Required by role 7

Callback tests.

File

tests/required_by_role_test/RequiredByRoleCallbackAlterTestCase.test
View source
<?php

/**
 * @file
 * Callback tests.
 */

/**
 *
 * @see DrupalUnitTestCase
 */
class RequiredByRoleCallbackAlterTestCase extends RequiredByRoleBasic {

  /**
   * GetInfo method.
   */
  public static function getInfo() {
    return array(
      'name' => 'Required by role: hook_required_by_role_callback_alter',
      'description' => 'Test that hook_required_by_role_callback_alter works properly.',
      'group' => 'Required by role',
    );
  }

  /**
   * Test the default callback.
   */
  public function testDefaultCallback() {
    $result = _required_by_role_get_callback();
    $callback = '_required_by_role_roles_intersect';
    $message = "The callback function should be {$callback}";
    $this
      ->assertEqual($result, $callback, $message);
  }

  /**
   * Test the hook_required_by_role_callback.
   */
  public function testContribModuleCallback() {
    $modules = array(
      'required_by_role_callback_test',
    );
    module_enable($modules);
    $result = _required_by_role_get_callback();
    $callback = 'required_by_role_callback_test_required_callback';
    $message = "The callback function should be {$callback}";
    $this
      ->assertEqual($result, $callback, $message);

    // Disable test modules to avoid set all fields required.
    module_disable($modules);
  }

}