You are here

function DatabaseAlterTestCase::testAlterWithJoin in SimpleTest 7

Test that we can alter the joins on a query.

File

tests/database_test.test, line 2160

Class

DatabaseAlterTestCase
Select alter tests.

Code

function testAlterWithJoin() {
  $query = db_select('test_task');
  $tid_field = $query
    ->addField('test_task', 'tid');
  $task_field = $query
    ->addField('test_task', 'task');
  $query
    ->orderBy($task_field);
  $query
    ->addTag('database_test_alter_add_join');
  $result = $query
    ->execute();
  $records = $result
    ->fetchAll();
  $this
    ->assertEqual(count($records), 2, t('Returned the correct number of rows.'));
  $this
    ->assertEqual($records[0]->name, 'George', t('Correct data retrieved.'));
  $this
    ->assertEqual($records[0]->{$tid_field}, 4, t('Correct data retrieved.'));
  $this
    ->assertEqual($records[0]->{$task_field}, 'sing', t('Correct data retrieved.'));
  $this
    ->assertEqual($records[1]->name, 'George', t('Correct data retrieved.'));
  $this
    ->assertEqual($records[1]->{$tid_field}, 5, t('Correct data retrieved.'));
  $this
    ->assertEqual($records[1]->{$task_field}, 'sleep', t('Correct data retrieved.'));
}