You are here

xmlsitemap_user.test in XML sitemap 7.2

Same filename and directory in other branches
  1. 6.2 xmlsitemap_user/xmlsitemap_user.test

Unit tests for the xmlsitemap_user module.

File

xmlsitemap_user/xmlsitemap_user.test
View source
<?php

/**
 * @file
 * Unit tests for the xmlsitemap_user module.
 */

/**
 * Tests for User Functional.
 */
class XMLSitemapUserFunctionalTest extends XMLSitemapTestHelper {

  /**
   * Normal User.
   *
   * @var string
   *
   * @codingStandardsIgnoreStart
   */
  protected $normal_user;

  /**
   * Accounts.
   *
   * @var array
   */
  protected $accounts = array();

  /**
   * Get Info.
   *
   * @codingStandardsIgnoreEnd
   */
  public static function getInfo() {
    return array(
      'name' => 'XML sitemap user',
      'description' => 'Functional tests for the XML sitemap user module.',
      'group' => 'XML sitemap',
    );
  }

  /**
   * Setup.
   */
  public function setUp($modules = array()) {
    $modules[] = 'xmlsitemap_user';
    parent::setUp($modules);

    // Save the user settings before creating the users.
    xmlsitemap_link_bundle_settings_save('user', 'user', array(
      'status' => 1,
      'priority' => 0.5,
    ));

    // Create the users.
    $this->admin_user = $this
      ->drupalCreateUser(array(
      'administer users',
      'administer permissions',
      'administer xmlsitemap',
    ));
    $this->normal_user = $this
      ->drupalCreateUser(array(
      'access content',
    ));

    // Update the normal user to make its sitemap link visible.
    $account = clone $this->normal_user;
    user_save($account, array(
      'access' => 1,
      'login' => 1,
    ));
  }

  /**
   * Blocked User().
   */
  public function testBlockedUser() {
    $this
      ->drupalLogin($this->admin_user);
    $this
      ->assertSitemapLinkVisible('user', $this->normal_user->uid);

    // Mark the user as blocked.
    $edit = array(
      'status' => 0,
    );

    // This will pass when https://www.drupal.org/node/360925 is fixed.
    $this
      ->drupalPost('user/' . $this->normal_user->uid . '/edit', $edit, t('Save'));
    $this
      ->assertText('The changes have been saved.');
    $this
      ->assertSitemapLinkNotVisible('user', $this->normal_user->uid);
  }

}

Classes

Namesort descending Description
XMLSitemapUserFunctionalTest Tests for User Functional.