views_handler_field_math.test

Definition of ViewsHandlerFieldMath.

File

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