Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / tests / handlers / views_handler_field_math.test @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of ViewsHandlerFieldMath.
6
 */
7

    
8
/**
9
 * Tests the core views_handler_field_math handler.
10
 */
11
class ViewsHandlerFieldMath extends ViewsSqlTest {
12
  public static function getInfo() {
13
    return array(
14
      'name' => 'Field: Math',
15
      'description' => 'Test the core views_handler_field_math handler.',
16
      'group' => 'Views Handlers',
17
    );
18
  }
19

    
20
  function viewsData() {
21
    $data = parent::viewsData();
22
    return $data;
23
  }
24

    
25
  public function testFieldCustom() {
26
    $view = $this->getBasicView();
27

    
28
    // Alter the text of the field to a random string.
29
    $rand1 = rand(0, 100);
30
    $rand2 = rand(0, 100);
31
    $view->display['default']->handler->override_option('fields', array(
32
      'expression' => array(
33
        'id' => 'expression',
34
        'table' => 'views',
35
        'field' => 'expression',
36
        'relationship' => 'none',
37
        'expression' => $rand1 . ' + ' . $rand2,
38
      ),
39
    ));
40

    
41
    $this->executeView($view);
42

    
43
    $this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression'));
44
  }
45

    
46
}