Projet

Général

Profil

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

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

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
  public static function getInfo() {
19
    return array(
20
      'name' => 'ReCaptcha admin UI test',
21
      'group' => 'reCAPTCHA',
22
      'description' => 'Tests reCaptcha admin UI'
23
    );
24
  }
25

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

    
36
    $this->drupalLogin($this->admin_user);
37
    $this->drupalGet(self::RECAPTCHA_ADMIN_PATH);
38
    $this->assertResponse(200);
39
    $this->assertField('recaptcha_server_status_check_interval');
40

    
41

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

    
53
}