Projet

Général

Profil

Paste
Télécharger (3,07 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / advanced_forum / tests / af.test @ 13c3c9b4

1
<?php
2

    
3
/**
4
 * @file
5
 * Unit tests for advanced_forum.module.
6
 */
7

    
8
/**
9
 * Class AfSimpleAPITest
10
 */
11
class AfSimpleAPITest extends DrupalUnitTestCase {
12

    
13
  public static function getInfo() {
14
    return array(
15
      'name' => 'Advanced Forum API sanity checks',
16
      'description' => 'Test the simple API functions in the public Advanced Forum API.',
17
      'group' => 'Advanced Forum',
18
    );
19
  }
20

    
21
  public function setUp() {
22
    drupal_load('module', 'advanced_forum');
23
    parent::setUp();
24
  }
25

    
26
  /**
27
   * Implements unit tests.
28
   */
29
  public function testAfFunctions() {
30

    
31
  }
32
}
33

    
34
/**
35
 * Class testAfFormsTestCase
36
 */
37
class testAfFormsTestCase extends DrupalWebTestCase {
38
  protected $privileged_user;
39

    
40
  public static function getInfo() {
41
    return array(
42
      'name' => 'Advanced Forum Forms',
43
      'description' => 'Advanced Forum Forms WebTesting.',
44
      'group' => 'Advanced Forum',
45
    );
46
  }
47

    
48
  /**
49
   * Implement setUp() method.
50
   */
51
  public function setUp() {
52
    // Enable any modules required for the test.
53
    parent::setUp('advanced_forum');
54
    // Create and log in our user. The user has the arbitrary privilege
55
    // 'extra special edit any simpletest_example' which the code uses
56
    // to grant access.
57
    $this->privileged_user = $this->drupalCreateUser(
58
      array('administer site configuration')
59
    );
60
    $this->drupalLogin($this->privileged_user);
61
  }
62

    
63
  /**
64
   * Implements admin form save.
65
   */
66
  public function testAfSaveConfig() {
67

    
68
    $edit = array();
69
    $this->privileged_user = $this->drupalCreateUser(
70
      array(
71
        'administer advanced forum',
72
        'view forum statistics',
73
        'view last edited notice'
74
      )
75
    );
76
    $this->drupalLogin($this->privileged_user);
77

    
78
    // Let's test all admin forms.
79
    $this->drupalPost(
80
      'admin/config/content/advanced-forum',
81
      $edit,
82
      t('Save configuration')
83
    );
84

    
85
    $this->assertText(t('The configuration options have been saved.'));
86
    
87
    $this->drupalGet('forum', $edit);
88
    $this->drupalGet('forum/active', $edit);
89
    $this->drupalGet('forum/unanswered', $edit);
90
    $this->drupalPost('forum/new', $edit, t('Apply'));
91
    $this->drupalPost('forum/unanswered', $edit, t('Apply'));
92
    $this->drupalPost('forum/active', $edit, t('Apply'));
93
    $edit1 = array('forum' => 1);
94
    $this->drupalPost('forum/new', $edit1, t('Apply'));
95
    $this->drupalPost('forum/unanswered', $edit1, t('Apply'));
96
    $this->drupalPost('forum/active', $edit1, t('Apply'));
97
    $this->drupalGet('forum/markasread', $edit);
98
    $edit2 = array('forum' => 'All');
99
    $this->drupalPost('forum/new', $edit2, t('Apply'));
100
    $this->drupalPost('forum/unanswered', $edit2, t('Apply'));
101
    $this->drupalPost('forum/active', $edit2, t('Apply'));
102
  }
103

    
104

    
105
  /**
106
   * Detect if we're running on PIFR testbot; skip intentional failure in that
107
   * case. It happens that on the testbot the site under test is in a directory
108
   * named 'checkout' or 'site_under_test'.
109
   *
110
   * @return boolean
111
   *   TRUE if running on testbot.
112
   */
113
  public function runningOnTestbot() {
114
    return (file_exists("../checkout") || file_exists("../site_under_test"));
115
  }
116
}