Projet

Général

Profil

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

root / drupal7 / sites / all / modules / fivestar / test / fivestar.base.test @ 76df55b7

1
<?php
2
/**
3
 * @file
4
 * Based test file for the Fivestar module.
5
 */
6

    
7
class FivestarBaseTestCase extends AJAXTestCase {
8
  // Using testing profile.
9
  // @see http://groups.drupal.org/node/217189
10
  protected $profile = 'testing';
11

    
12
  // Set up our basic users.
13
  protected $admin_user;
14
  protected $voter;
15
  
16
  public function setUp() {
17
    parent::setUp(array('fivestar', 'dblog'));
18

    
19
    $type = $this->drupalCreateContentType(array('type' => 'test_node_type', 'name' => 'test_node_type'));
20
    $this->admin_user = $this->drupalCreateUser(array('create test_node_type content', 'rate content'));
21
    $this->voter_user = $this->drupalCreateUser(array('rate content'));
22
 }
23

    
24
  /**
25
   * Add a fivestar field to a content type.
26
   *
27
   * @param $options
28
   *   An associative array of options for the field and instance.
29
   */
30
  public function createFivestarField($options = array()) {
31
    $options = $options + array(
32
      'content_type' => 'test_node_type',
33
      'widget_type' => 'stars',
34
      'display' => array(),
35
    );
36
    $field = array(
37
      'field_name' => 'fivestar_test',
38
      'type' => 'fivestar',
39
      'cardinality' => 1,
40
      'settings' => array(
41
        'axis' => 'vote',
42
      ),
43
    );
44
    $instance = array(
45
      'entity_type' => 'node',
46
      'field_name' => 'fivestar_test',
47
      'label' => 'Fivestar test field',
48
      'bundle' => $options['content_type'],
49
      'widget' => array(
50
        'type' => $options['widget_type'],
51
        'settings' => array(
52
          'widget' => array(
53
            'fivestar_widget' => 'default',
54
          ),
55
        ),
56
      ),
57
      'settings' => array(
58
        'axis' => 'vote',
59
        'stars' => '5',
60
      ),
61
      'display' => $options['display'],
62
    );
63

    
64
    field_create_field($field);
65
    field_create_instance($instance);
66
  }
67
}