og_sm-8.x-1.0/og_sm_taxonomy/tests/OgSmTaxonomyTokensTestCase.test

og_sm_taxonomy/tests/OgSmTaxonomyTokensTestCase.test
<?php
/**
 * @file
 * Tests for the og_sm_path module.
 */

/**
 * Tests about the Site Path tokens.
 */
class OgSmTaxonomyTokensTestCase extends OgSmWebTestCase {
  /**
   * The Site node to test with.
   *
   * @param object
   */
  private $nodeSite;

  /**
   * The Site node path to test with.
   *
   * @param string
   */
  private $nodePath;

  /**
   * Vocabulary "categories" to run tests with.
   *
   * @var object
   */
  private $vocabCategories;

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return array(
      'name' => t('Site Taxonomy : Tokens'),
      'description' => t('Tests Site Taxonomy tokens.'),
      'group' => t('Organic Groups Site Manager'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    // Enable required modules.
    $modules = array('og_sm_path', 'og_sm_taxonomy');
    parent::setUp($modules);

    // Create the Site node with his path.
    $type = $this->ogSmCreateGroupNodeType();
    og_sm_site_type_add($type);
    $this->nodeSite = $this->ogSmCreateGroup($type);
    $this->nodePath = 'test-path-token';
    og_sm_path_set($this->nodeSite, $this->nodePath, FALSE);

    // Create vocabulary.
    $this->vocabCategories = $this->ogSmCreateGroupVocabulary('test_categories');
  }

  /**
   * Test the token generation.
   */
  public function testSiteTokens() {
    module_load_include('inc', 'og_sm_taxonomy', 'og_sm_taxonomy.tokens');

    // Create a term outside the Site.
    $termGlobal = $this->ogSmCreateTerm($this->vocabCategories, 'term-name');

    // Create a term inside the Site.
    $termSite = $this->ogSmCreateTerm($this->vocabCategories, 'term-name', array($this->nodeSite));

    $type = 'term';
    $tokens = array('site-path');

    // No tokens for term outside a Site.
    $data = array('term' => $termGlobal);
    $this->assertEqual(
      array(),
      og_sm_taxonomy_tokens($type, $tokens, $data),
      'Term without Site does not have the Site path token.'
    );

    // Token for term inside a Site.
    $expected = array('site-path' => $this->nodePath);
    $data = array('term' => $termSite);
    $this->assertEqual(
      $expected,
      og_sm_taxonomy_tokens($type, $tokens, $data),
      'Term that is member of a Site does have the Site path token.'
    );
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc