You are here

function FaqAskTestCase::setUp in FAQ_Ask 6.2

Implementation of setUp().

Overrides DrupalWebTestCase::setUp

File

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

Class

FaqAskTestCase
Base class that is extended by test cases.

Code

function setUp() {

  // Install FAQ Module.
  parent::setUp('taxonomy', 'faq', 'faq_ask');

  // 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',
    'administer content types',
  ));
  $this->faq_user = $this
    ->drupalCreateUser(array(
    'create faq',
    'edit faq',
    'delete faq content',
    'view faq page',
    'access content',
  ));
  $this->view_faq_user = $this
    ->drupalCreateUser(array(
    'view faq page',
    'access content',
  ));
  $this->faq_asker = $this
    ->drupalCreateUser(array(
    'view faq page',
    'access content',
    'ask question',
    'create faq',
    'edit faq',
  ));
  $this->faq_expert = $this
    ->drupalCreateUser(array(
    'view faq page',
    'edit own faq',
    'edit faq',
    'access content',
    'answer question',
  ));
  $roles = $this->faq_expert->roles;
  end($roles);
  $this
    ->pass(print_r($roles, TRUE));
  $this->expert_role = key($roles);

  // Set to last role (the unique one)
  $this
    ->drupalLogin($this->admin_user);

  // Set up the vocab and terms.
  $this
    ->faqAskSetupTaxonomy();

  // Categorize questions.
  $this
    ->drupalPost('admin/settings/faq/categories', array(
    'faq_use_categories' => '1',
  ), t('Save configuration'));

  //    $this->drupalPost('admin/user/roles', array('name' => 'expert'), 'Add role');
  //    $this->assertText('The role has been added.', 'New role created');
  //    $this->drupalPost('admin/user/permissions/3', array('3[create faq]' => TRUE, '3[answer question]' => TRUE), 'Save permissions');
  // Set up expert on settings page for faq_ask
  $this
    ->drupalGet('admin/settings/faq/ask');
  $edit = array(
    'faq_ask_notify' => TRUE,
    'faq_ask_asker_notify' => TRUE,
    'faq_ask_asker_notify_indication' => FALSE,
    'faq_expert_role[]' => array(
      $this->faq_expert->uid,
    ),
  );
  $this
    ->drupalPost('admin/settings/faq/ask', $edit, 'Save configuration');
  $edit = array();
  $checkboxname = 'expert_' . $this->faq_expert->uid . '_1';
  $edit[$checkboxname] = TRUE;

  // Creates something like: expert_7_1 where 7 is the uid of the expert and 1 is the first column
  $edit['faq_ask_default_expert'] = $this->faq_expert->uid;
  $this
    ->drupalPost('admin/settings/faq/ask', $edit, 'Save configuration');

  // Set answer_user as default expert.
  $roles = $this->faq_expert->roles;
  end($roles);

  // Set to last role (the unique one)
  // Start all tests logged out.
  $this
    ->drupalLogout();
}