You are here

public function ViewsUpgradeTestCase::testMovedTo in Views (for Drupal 7) 7.3

Tests the moved to parameter in general.

File

tests/views_upgrade.test, line 70
Definition of ViewsUpgradeTestCase.

Class

ViewsUpgradeTestCase
Try to test the upgrade path of all conversions.

Code

public function testMovedTo() {

  // Test moving on field lavel.
  $view = $this
    ->viewsMovedToField();
  $view
    ->update();
  $view
    ->build();

  // $this->assertEqual('old_field_1',
  //   $view->field['old_field_1']->options['id'],
  //   "Id shouldn't change during conversion");
  // $this->assertEqual('id', $view->field['old_field_1']->field,
  //   'The field should change during conversion');
  $this
    ->assertEqual('id', $view->field['old_field_1']->real_field);
  $this
    ->assertEqual('views_test', $view->field['old_field_1']->table);
  $this
    ->assertEqual('old_field_1', $view->field['old_field_1']->original_field, 'The field should have stored the original_field');

  // Test moving on handler lavel.
  $view = $this
    ->viewsMovedToHandler();
  $view
    ->update();
  $view
    ->build();

  // $this->assertEqual('old_field_2',
  //   $view->field['old_field_2']->options['id']);
  $this
    ->assertEqual('name', $view->field['old_field_2']->real_field);
  $this
    ->assertEqual('views_test', $view->field['old_field_2']->table);

  // $this->assertEqual('old_field_3',
  //   $view->filter['old_field_3']->options['id']);
  $this
    ->assertEqual('age', $view->filter['old_field_3']->real_field);
  $this
    ->assertEqual('views_test', $view->filter['old_field_3']->table);

  // Test moving on table level.
  $view = $this
    ->viewsMovedToTable();
  $view
    ->update();
  $view
    ->build();
  $this
    ->assertEqual('views_test', $view->base_table, 'Make sure that view->base_table gets automatically converted.');

  // $this->assertEqual('id', $view->field['id']->field,
  //  'If we move a whole table fields of this table should work, too.');
  $this
    ->assertEqual('id', $view->field['id']->real_field, 'To run the query right the real_field has to be set right.');
  $this
    ->assertEqual('views_test', $view->field['id']->table);
}