views_handler_field_xss.test

Definition of ViewsHandlerTestXss.

File

tests/handlers/views_handler_field_xss.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerTestXss.
  5. */
  6. /**
  7. * Tests the core views_handler_field_css handler.
  8. *
  9. * @see CommonXssUnitTest
  10. */
  11. class ViewsHandlerTestXss extends ViewsSqlTest {
  12. public static function getInfo() {
  13. return array(
  14. 'name' => 'Field: Xss',
  15. 'description' => 'Test the core views_handler_field_css handler.',
  16. 'group' => 'Views Handlers',
  17. );
  18. }
  19. function dataHelper() {
  20. $map = array(
  21. 'John' => 'John',
  22. "Foo\xC0barbaz" => '',
  23. 'Fooÿñ' => 'Fooÿñ'
  24. );
  25. return $map;
  26. }
  27. function viewsData() {
  28. $data = parent::viewsData();
  29. $data['views_test']['name']['field']['handler'] = 'views_handler_field_xss';
  30. return $data;
  31. }
  32. public function testFieldXss() {
  33. $view = $this->getBasicView();
  34. $view->display['default']->handler->override_option('fields', array(
  35. 'name' => array(
  36. 'id' => 'name',
  37. 'table' => 'views_test',
  38. 'field' => 'name',
  39. ),
  40. ));
  41. $this->executeView($view);
  42. $counter = 0;
  43. foreach ($this->dataHelper() as $input => $expected_result) {
  44. $view->result[$counter]->views_test_name = $input;
  45. $this->assertEqual($view->field['name']->advanced_render($view->result[$counter]), $expected_result);
  46. $counter++;
  47. }
  48. }
  49. }