You are here

function Faq_AskTestCase::setUp in FAQ_Ask 7

Implementation of setUp(). Array of additional modules to be installed are passed as parameter

Overrides DrupalWebTestCase::setUp

1 call to Faq_AskTestCase::setUp()
Faq_askMailchimpTestCase::setUp in ./faq_ask.test
Implementation of setUp(). Array of additional modules to be installed are passed as parameter
1 method overrides Faq_AskTestCase::setUp()
Faq_askMailchimpTestCase::setUp in ./faq_ask.test
Implementation of setUp(). Array of additional modules to be installed are passed as parameter

File

./faq_ask.test, line 34
Test Faq_Ask functionality Base test class. All tests inherits this one Hugely based on code from the test file block.test by boombatower

Class

Faq_AskTestCase
Base class that is extended by test cases

Code

function setUp($modules = NULL) {

  // Install FAQ Module
  $module_list = array(
    'taxonomy',
    'faq',
    'faq_ask',
  );
  if (!empty($modules)) {
    $module_list = array_merge($module_list, $modules);
  }
  parent::setUp($module_list);

  // Create and log in user with administer taxonomy permissions.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer users',
    'administer permissions',
    'administer taxonomy',
    'administer faq',
    'administer faq order',
    'administer blocks',
  ));
  $this->faq_user = $this
    ->drupalCreateUser(array(
    'create faq content',
    'edit any faq content',
    'delete any faq content',
    'view faq page',
    'access content',
  ));
  $this->view_faq_user = $this
    ->drupalCreateUser(array(
    'view faq page',
    'access content',
  ));
  $this->ask_user = $this
    ->drupalCreateUser(array(
    'view faq page',
    'ask question',
    'create faq content',
    'edit own faq content',
    'view own unpublished content',
  ));
  $this->answer_user = $this
    ->drupalCreateUser(array(
    'answer question',
    'view faq page',
    'edit any faq content',
  ));
  $this->answer_user2 = $this
    ->drupalCreateUser(array(
    'answer question',
    'view faq page',
    'edit any faq content',
  ));
  $roles = array_flip($this->answer_user->roles);
  unset($roles['authenticated user']);
  $this->answer_user2->roles = $roles = array_flip($roles);

  // Add second user to the role of answering
  end($roles);
  $this
    ->pass(print_r($roles, TRUE));
  $this->expert_role = key($roles);

  // Set to last role (the unique one)
  $this
    ->pass(print_r($this->answer_user2, TRUE));
  $this
    ->drupalLogin($this->admin_user);

  // Set up the vocab and terms
  $this
    ->setupTaxonomy();
  $this
    ->drupalLogin($this->admin_user);

  // Categorize questions
  $this
    ->drupalPost('admin/config/content/faq', array(
    'faq_description' => 'Faq-page description text',
  ), t('Save configuration'));
  $this
    ->drupalPost('admin/config/content/faq/questions', array(
    'faq_question_length' => 'both',
  ), t('Save configuration'));
  $this
    ->drupalPost('admin/config/content/faq/categories', array(
    'faq_use_categories' => TRUE,
    'faq_answer_category_name' => TRUE,
    'faq_group_questions_top' => TRUE,
  ), t('Save configuration'));

  // Set the default expert to answer user
  // Set answer_user as default expert
  $roles = $this->answer_user->roles;

  //end($roles);  // Set to last role (the unique one)
  $this
    ->pass('<pre>' . print_r($this->answer_user, TRUE) . '</pre>');

  // Set expert role
  $settings = array(
    'faq_expert_role[]' => $this->expert_role,
    // key($roles),
    //        'faq_category_field' => 'taxonomy_' . $this->vocabulary->machine_name,
    'faq_ask_vocabularies[]' => array(
      $this->term->vid,
    ),
  );
  $this
    ->setFaqAskSettings($settings);

  // Set default expert
  //    $this->drupalPost('admin/config/content/faq/ask', array('expert_1_1' => '0', 'expert_'.$this->answer_user->uid.'_1' => '1'), t('Save configuration'));
  $this
    ->setFaqAskSettings(array(
    'expert_1_1' => '0',
    'expert_' . $this->answer_user->uid . '_1' => '1',
  ));

  //    $this->drupalPost('admin/config/content/faq/ask', array('faq_ask_default_expert' => $this->answer_user->uid), t('Save configuration'));
  $this
    ->setFaqAskSettings(array(
    'faq_ask_default_expert' => $this->answer_user->uid,
  ));

  // $this->pass('<pre>'.var_export($this->answer_user, TRUE).'</pre>');          // Show us the node loaded
  // Select the Unanswered questions block to be configured and moved.
  $this
    ->turnBlockOn('faq_ask', 'unanswered');
}