Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / tests / handlers / views_handler_field_xss.test @ 5d12d676

1
<?php
2

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

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

    
22
  function dataHelper() {
23
    $map = array(
24
      'John' => 'John',
25
      "Foo\xC0barbaz" => '',
26
      'Fooÿñ' => 'Fooÿñ',
27
    );
28

    
29
    return $map;
30
  }
31

    
32

    
33
  function viewsData() {
34
    $data = parent::viewsData();
35
    $data['views_test']['name']['field']['handler'] = 'views_handler_field_xss';
36

    
37
    return $data;
38
  }
39

    
40
  public function testFieldXss() {
41
    $view = $this->getBasicView();
42

    
43
    $view->display['default']->handler->override_option('fields', array(
44
      'name' => array(
45
        'id' => 'name',
46
        'table' => 'views_test',
47
        'field' => 'name',
48
      ),
49
    ));
50

    
51
    $this->executeView($view);
52

    
53
    $counter = 0;
54
    foreach ($this->dataHelper() as $input => $expected_result) {
55
      $view->result[$counter]->views_test_name = $input;
56
      $this->assertEqual($view->field['name']->advanced_render($view->result[$counter]), $expected_result);
57
      $counter++;
58
    }
59
  }
60

    
61
}