You are here

function FaqAskTestCase::faqAskSetupTaxonomy in FAQ_Ask 6.2

Set up the taxonomy - all vocabularies and stuff Values also stored in protected variable $tax

1 call to FaqAskTestCase::faqAskSetupTaxonomy()
FaqAskTestCase::setUp in ./faq_ask.test
Implementation of setUp().

File

./faq_ask.test, line 148
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 faqAskSetupTaxonomy() {

  // Create vocabulary.
  $this->taxonomy = array();
  $this->taxonomy['name'] = $this
    ->randomName(8);

  // Create taxonomy vocabulary name
  $this->taxonomy['description'] = $this
    ->randomName(64);
  $this->taxonomy['nodes[faq]'] = '1';

  // Assign vocab to FAQ node types
  $this->taxonomy['tags'] = '1';

  // Users may create tags
  $this->taxonomy['multiple'] = '1';

  // may have more than one tag
  $this->taxonomy['required'] = '1';

  // but minimum 1 tag
  $this
    ->drupalPost('admin/content/taxonomy/add/vocabulary', $this->taxonomy, t('Save'));
  $this
    ->assertText(t('Created new vocabulary @name', array(
    '@name' => $this->taxonomy['name'],
  )));
  $this
    ->assertText(t('FAQ'));

  // Add term
  // Click the last occurrence of the link.
  $this
    ->clickLink(t('add terms'), substr_count($this
    ->drupalGetContent(), 'add terms') - 1);
  $this
    ->assertText(t('Add term to @name', array(
    '@name' => $this->taxonomy['name'],
  )));
  if (isset($url['query'])) {
    $url = parse_url($this
      ->getUrl());
    if ($url['query'] == '') {
      $array = split('/', $url['path']);
      $this->taxonomy['id'] = $array[4];
    }
    else {
      $array = split('/', $url['query']);
      $this->taxonomy['id'] = $array[3];
    }
    $this
      ->pass(var_export($array, TRUE));
  }
  $url = $this
    ->getUrl();
  $this->term1 = array();
  $this->term1['name'] = 'term1-' . $this
    ->randomName(8);

  // Create taxonomy vocabulary name
  $this->term1['description'] = $this
    ->randomName(64);
  $this
    ->drupalPost($url, $this->term1, t('Save'));
  $this
    ->assertText(t('Created new term @name', array(
    '@name' => $this->term1['name'],
  )));
  $this->term2 = array();
  $this->term2['name'] = 'term2-' . $this
    ->randomName(8);

  // Create taxonomy vocabulary name
  $this->term2['description'] = $this
    ->randomName(64);
  $this
    ->drupalPost($url, $this->term2, t('Save'));
  $this
    ->assertText(t('Created new term @name', array(
    '@name' => $this->term2['name'],
  )));
}