You are here

public function QuizTestCase::setUp in Quiz 7.5

Same name and namespace in other branches
  1. 7.6 tests/QuizTestCase.test \QuizTestCase::setUp()

Set up a question test case.

Parameters

array $modules: Array of modules to enable.

array $admin_permissions: Array of admin permissions to add.

array $user_permissions: Array of user permissions to add.

Overrides DrupalWebTestCase::setUp

11 calls to QuizTestCase::setUp()
QuizAccessTestCase::setUp in tests/QuizAccessTestCase.test
Set up a question test case.
QuizCreationTestCase::setUp in tests/QuizCreationTestCase.test
Set up a question test case.
QuizFeedbackTestCase::setUp in tests/QuizFeedbackTestCase.test
Set up a question test case.
QuizGradingTestCase::setUp in tests/QuizGradingTestCase.test
Set up a question test case.
QuizNavigationTestCase::setUp in tests/QuizNavigationTestCase.test
Set up a question test case.

... See full list

11 methods override QuizTestCase::setUp()
QuizAccessTestCase::setUp in tests/QuizAccessTestCase.test
Set up a question test case.
QuizCreationTestCase::setUp in tests/QuizCreationTestCase.test
Set up a question test case.
QuizFeedbackTestCase::setUp in tests/QuizFeedbackTestCase.test
Set up a question test case.
QuizGradingTestCase::setUp in tests/QuizGradingTestCase.test
Set up a question test case.
QuizNavigationTestCase::setUp in tests/QuizNavigationTestCase.test
Set up a question test case.

... See full list

File

tests/QuizTestCase.test, line 25
Unit tests for the quiz question Module.

Class

QuizTestCase
Base test class for Quiz questions.

Code

public function setUp($modules = array(), $admin_permissions = array(), $user_permissions = array()) {
  $modules[] = 'quiz';
  $modules[] = 'quiz_question';
  parent::setUp($modules);

  // Add text formats.
  $filtered_html_format = array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // HTML filter.
      'filter_html' => array(
        'weight' => 1,
        'status' => 1,
      ),
      // Line break filter.
      'filter_autop' => array(
        'weight' => 2,
        'status' => 1,
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  );
  $filtered_html_format = (object) $filtered_html_format;
  filter_format_save($filtered_html_format);
  $full_html_format = array(
    'format' => 'full_html',
    'name' => 'Full HTML',
    'weight' => 1,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // Line break filter.
      'filter_autop' => array(
        'weight' => 1,
        'status' => 1,
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  );
  $full_html_format = (object) $full_html_format;
  filter_format_save($full_html_format);

  // Enable default permissions for system roles.
  $filtered_html_permission = filter_permission_name($filtered_html_format);
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
    $filtered_html_permission,
  ));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    $filtered_html_permission,
  ));
  $admin_permissions[] = 'administer quiz configuration';
  $admin_permissions[] = 'create quiz content';
  $admin_permissions[] = 'edit any quiz content';
  $admin_permissions[] = 'edit question titles';
  $admin_permissions[] = 'access quiz';
  $user_permissions[] = 'access quiz';
  $this->admin = $this
    ->drupalCreateUser(array_unique($admin_permissions));
  $this->user = $this
    ->drupalCreateUser(array_unique($user_permissions));
}