You are here

site_map.test in Site map 7

Tests for the site_map module.

File

site_map.test
View source
<?php

/**
 * @file
 * Tests for the site_map module.
 */

/**
 * Test case class for sitemap tests.
 */
class SiteMapTest extends DrupalWebTestCase {

  /**
   * The getInfo() method provides information about the test.
   *
   * In order for the test to be run, the getInfo() method needs
   * to be implemented.
   */
  public static function getInfo() {
    return array(
      'name' => t('Site map'),
      'description' => t('Tests main module logic.'),
      'group' => t('Sitemap'),
    );
  }

  /**
   * Prepares the testing environment.
   */
  public function setUp() {
    parent::setUp('site_map');
  }

  /**
   * Tests that a new node with a menu item gets listed at /sitemap.
   */
  public function testNodeAddition() {

    // Create user.
    $this->user = $this
      ->drupalCreateUser(array(
      'administer site map',
      'access site map',
      'administer menu',
      'administer nodes',
      'create page content',
    ));
    $this
      ->drupalLogin($this->user);

    // Configure module to list items of Main menu.
    $edit = array(
      'site_map_show_menus[main-menu]' => '1',
    );
    $this
      ->drupalPost('admin/config/search/sitemap', $edit, t('Save configuration'));
    $this
      ->assertText(t('The configuration options have been saved.'));

    // Create dummy node.
    $title = $this
      ->randomName(8);
    $edit = array(
      'title' => $title,
      'menu[enabled]' => '1',
      'menu[link_title]' => $title,
    );
    $this
      ->drupalPost('node/add/page', $edit, t('Save'));

    // Check that dummy node is listed at /sitemap.
    $this
      ->drupalGet('sitemap');
    $this
      ->assertText($title);
  }

}

Classes

Namesort descending Description
SiteMapTest Test case class for sitemap tests.