You are here

public function ViewsHandlerFieldVariableTest::testFieldVariable in Views Variable Field 7

File

./vvf.test, line 26
Definition of ViewsHandlerFieldVariableTest.

Class

ViewsHandlerFieldVariableTest
Tests the vvf views_handler_field_variable handler.

Code

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

  // Set random variable name and value.
  $variable = $this
    ->randomName();
  $value = $this
    ->randomName();
  variable_set($variable, $value);
  variable_set('variable_name', $variable);
  $view->display['default']->handler
    ->override_option('fields', array(
    'variable' => array(
      'id' => 'variable',
      'table' => 'views',
      'field' => 'variable',
      'relationship' => 'none',
      'variable_name' => $variable,
    ),
    'variable_name' => array(
      'id' => 'variable_1',
      'table' => 'views',
      'field' => 'variable',
      'relationship' => 'none',
      'variable_name' => 'variable_name',
    ),
    'variable_placeholder' => array(
      'id' => 'variable_2',
      'table' => 'views',
      'field' => 'variable',
      'relationship' => 'none',
      'variable_name' => '[variable_name]',
    ),
  ));
  $this
    ->executeView($view);
  $this
    ->assertEqual($value, $view->style_plugin
    ->get_field(0, 'variable'));
  $this
    ->assertEqual($variable, $view->style_plugin
    ->get_field(0, 'variable_name'));
  $this
    ->assertEqual($value, $view->style_plugin
    ->get_field(0, 'variable_placeholder'));
}