You are here

function SchemaRegressionTest::testInspectionConflict518210 in Schema 6

Same name and namespace in other branches
  1. 7 tests/schema_regression.test \SchemaRegressionTest::testInspectionConflict518210()

Test API for adding tables

File

tests/schema_regression.test, line 31
Regression tests for the Schema module

Class

SchemaRegressionTest
@file Regression tests for the Schema module

Code

function testInspectionConflict518210() {

  // Create an unprefixed table...
  $tablename = "schema_testtbl";
  $sql = "CREATE TABLE {$tablename} (\n              fid INT NOT NULL,\n              destid INT NOT NULL\n            )";
  db_query($sql);

  // ...and a prefixed table, with a different column list
  $ret = array();
  $schema = array(
    'fields' => array(
      'sourceid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'destid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
  );
  db_create_table($ret, $tablename, $schema);

  // Do the full inspection, and get our specified tablename
  $inspect = schema_invoke('inspect');
  $fields = $inspect[$tablename]['fields'];

  // We should see only the columns from the prefixed version
  $this
    ->assertFalse(isset($fields['fid']), t('fid does not exist'));
  $this
    ->assertTrue(isset($fields['sourceid']), t('sourceid exists'));
  $this
    ->assertTrue(isset($fields['destid']), t('destid exists'));

  // Inspect the table by using schema_compare().
  $comparison = schema_compare_table($inspect[$tablename]);
  $this
    ->assertEqual($comparison['status'], 'same');
}