views_handler_field_custom.test

Definition of ViewsHandlerFieldCustomTest.

File

tests/handlers/views_handler_field_custom.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerFieldCustomTest.
  5. */
  6. /**
  7. * Tests the core views_handler_field_custom handler.
  8. */
  9. class ViewsHandlerFieldCustomTest extends ViewsSqlTest {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Field: Custom',
  13. 'description' => 'Test the core views_handler_field_custom handler.',
  14. 'group' => 'Views Handlers',
  15. );
  16. }
  17. function viewsData() {
  18. $data = parent::viewsData();
  19. $data['views_test']['name']['field']['handler'] = 'views_handler_field_custom';
  20. return $data;
  21. }
  22. public function testFieldCustom() {
  23. $view = $this->getBasicView();
  24. // Alter the text of the field to a random string.
  25. $random = $this->randomName();
  26. $view->display['default']->handler->override_option('fields', array(
  27. 'name' => array(
  28. 'id' => 'name',
  29. 'table' => 'views_test',
  30. 'field' => 'name',
  31. 'relationship' => 'none',
  32. 'alter' => array(
  33. 'text' => $random,
  34. ),
  35. ),
  36. ));
  37. $this->executeView($view);
  38. $this->assertEqual($random, $view->style_plugin->get_field(0, 'name'));
  39. }
  40. }