summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test
blob: b45fd1770d7eee14ac58bb95b216b0f8c34958ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

/**
 * @file
 * Definition of ViewsHandlerFieldCustomTest.
 */

/**
 * Tests the core views_handler_field_custom handler.
 */
class ViewsHandlerFieldCustomTest extends ViewsSqlTest {
  public static function getInfo() {
    return array(
      'name' => 'Field: Custom',
      'description' => 'Test the core views_handler_field_custom handler.',
      'group' => 'Views Handlers',
    );
  }

  function viewsData() {
    $data = parent::viewsData();
    $data['views_test']['name']['field']['handler'] = 'views_handler_field_custom';
    return $data;
  }

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

    // Alter the text of the field to a random string.
    $random = $this->randomName();
    $view->display['default']->handler->override_option('fields', array(
      'name' => array(
        'id' => 'name',
        'table' => 'views_test',
        'field' => 'name',
        'relationship' => 'none',
        'alter' => array(
          'text' => $random,
        ),
      ),
    ));

    $this->executeView($view);

    $this->assertEqual($random, $view->style_plugin->get_field(0, 'name'));
  }
}