You are here

function FaqTestCase::setUp in Frequently Asked Questions 6

Same name and namespace in other branches
  1. 7.2 faq.test \FaqTestCase::setUp()
  2. 7 faq.test \FaqTestCase::setUp()

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

File

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

Class

FaqTestCase
Base class that is extended by test cases.

Code

function setUp() {

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

  // Create and log in user with administer taxonomy permissions.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer taxonomy',
    'administer faq',
    'administer faq order',
    'administer blocks',
  ));
  $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
    ->drupalLogin($this->admin_user);

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

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

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

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