HEX
Server: Apache
System: Linux webm010.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: iestorre (46869)
PHP: 8.0.30
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/iestorre/www2/modules/views/tests/handlers/views_handler_field_math.test
<?php
module_load_include('test', 'views', 'tests/views_query');

class ViewsHandlerFieldMath extends ViewsSqlTest {
  public static function getInfo() {
    return array(
      'name' => 'Field: Math',
      'description' => 'Test the core views_handler_field_math handler.',
      'group' => 'Views Handlers',
    );
  }

  function setUp() {
    parent::setUp();
    module_enable(array('ctools'));
  }


  function viewsData() {
    $data = parent::viewsData();
    return $data;
  }

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

    // Alter the text of the field to a random string.
    $rand1 = rand(0, 100);
    $rand2 = rand(0, 100);
    $view->display['default']->handler->override_option('fields', array(
      'expression' => array(
        'id' => 'expression',
        'table' => 'views',
        'field' => 'expression',
        'relationship' => 'none',
        'expression' => $rand1 . ' + ' . $rand2,
      ),
    ));

    $this->executeView($view);

    $this->assertEqual($rand1 + $rand2, $view->field['expression']->render($view->result[0]));
  }
}