Projet

Général

Profil

Paste
Télécharger (1,58 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / recaptcha / tests / recaptcha_ui.test @ 4f315dab

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains ReCaptcha.
6
 */
7

    
8
/**
9
 * Test cases for ReCaptcha module UI.
10
 */
11
class ReCaptchaAdminUITestCase extends ReCaptchaBaseTestCase {
12

    
13
  /**
14
   * Drupal path of the (general) CAPTCHA admin page.
15
   */
16
  const RECAPTCHA_ADMIN_PATH = 'admin/config/people/captcha/recaptcha';
17

    
18
  /**
19
   *
20
   */
21
  public static function getInfo() {
22
    return array(
23
      'name' => 'ReCaptcha admin UI test',
24
      'group' => 'reCAPTCHA',
25
      'description' => 'Tests reCaptcha admin UI',
26
    );
27
  }
28

    
29
  /**
30
   * Test access to the admin pages.
31
   */
32
  public function testAdminAccess() {
33
    $this->drupalLogin($this->normal_user);
34
    $this->drupalGet(self::RECAPTCHA_ADMIN_PATH);
35
    file_put_contents('tmp.simpletest.html', $this->drupalGetContent());
36
    $this->assertText(t('Access denied'), 'Normal users should not be able to access the CAPTCHA admin pages', 'CAPTCHA');
37
    $this->assertResponse(403);
38

    
39
    $this->drupalLogin($this->admin_user);
40
    $this->drupalGet(self::RECAPTCHA_ADMIN_PATH);
41
    $this->assertResponse(200);
42
    $this->assertField('recaptcha_server_status_check_interval');
43

    
44
    // Update the interval and make sure it get saved properly.
45
    $edit = array(
46
      'recaptcha_server_status_check_interval' => 20,
47
      'recaptcha_public_key' => '6LekT84SAAAAAE0AqDpG5IrtKoyr7OOiE82MtXgJ',
48
      'recaptcha_private_key' => '6LekT84SAAAAAE0AqDpG5IrtKoyr7OOiE81MtXgJ',
49
    );
50
    $this->drupalPost(NULL, $edit, t('Save configuration'));
51
    $this->assertText(t('The configuration options have been saved.'));
52
    $this->assertFieldByName('recaptcha_server_status_check_interval', 20);
53
  }
54

    
55
}