xmlsitemap_user.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @file
  4. * Unit tests for the xmlsitemap_user module.
  5. */
  6. /**
  7. * Tests for User Functional.
  8. */
  9. class XMLSitemapUserFunctionalTest extends XMLSitemapTestHelper {
  10. /**
  11. * Normal User.
  12. *
  13. * @var string
  14. *
  15. * @codingStandardsIgnoreStart
  16. */
  17. protected $normal_user;
  18. /**
  19. * Accounts.
  20. *
  21. * @var array
  22. */
  23. protected $accounts = array();
  24. /**
  25. * Get Info.
  26. *
  27. * @codingStandardsIgnoreEnd
  28. */
  29. public static function getInfo() {
  30. return array(
  31. 'name' => 'XML sitemap user',
  32. 'description' => 'Functional tests for the XML sitemap user module.',
  33. 'group' => 'XML sitemap',
  34. );
  35. }
  36. /**
  37. * Setup.
  38. */
  39. public function setUp($modules = array()) {
  40. $modules[] = 'xmlsitemap_user';
  41. parent::setUp($modules);
  42. // Save the user settings before creating the users.
  43. xmlsitemap_link_bundle_settings_save('user', 'user', array('status' => 1, 'priority' => 0.5));
  44. // Create the users.
  45. $this->admin_user = $this->drupalCreateUser(array(
  46. 'administer users',
  47. 'administer permissions',
  48. 'administer xmlsitemap',
  49. ));
  50. $this->normal_user = $this->drupalCreateUser(array('access content'));
  51. // Update the normal user to make its sitemap link visible.
  52. $account = clone $this->normal_user;
  53. user_save($account, array('access' => 1, 'login' => 1));
  54. }
  55. /**
  56. * Blocked User().
  57. */
  58. public function testBlockedUser() {
  59. $this->drupalLogin($this->admin_user);
  60. $this->assertSitemapLinkVisible('user', $this->normal_user->uid);
  61. // Mark the user as blocked.
  62. $edit = array(
  63. 'status' => 0,
  64. );
  65. // This will pass when https://www.drupal.org/node/360925 is fixed.
  66. $this->drupalPost('user/' . $this->normal_user->uid . '/edit', $edit, t('Save'));
  67. $this->assertText('The changes have been saved.');
  68. $this->assertSitemapLinkNotVisible('user', $this->normal_user->uid);
  69. }
  70. }