summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test
blob: 527e94fb41265629712e1fd325fb0c2ae25d215b (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
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

/**
 * @file
 * Definition of ViewsHandlerFieldUrlTest.
 */

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

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

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

    $view->display['default']->handler->override_option('fields', array(
      'name' => array(
        'id' => 'name',
        'table' => 'views_test',
        'field' => 'name',
        'relationship' => 'none',
        'display_as_link' => FALSE,
      ),
    ));

    $this->executeView($view);

    $this->assertEqual('John', $view->field['name']->advanced_render($view->result[0]));

    // Make the url a link.
    $view->delete();
    $view = $this->getBasicView();

    $view->display['default']->handler->override_option('fields', array(
      'name' => array(
        'id' => 'name',
        'table' => 'views_test',
        'field' => 'name',
        'relationship' => 'none',
      ),
    ));

    $this->executeView($view);

    $this->assertEqual(l('John', 'John'), $view->field['name']->advanced_render($view->result[0]));
  }
}