You are here

schema_regression.test in Schema 7

Same filename and directory in other branches
  1. 6 tests/schema_regression.test

Regression tests for the Schema module

File

tests/schema_regression.test
View source
<?php

/**
 * @file
 * Regression tests for the Schema module
 *
 */
class SchemaRegressionTest extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Schema Regression Tests',
      'description' => 'Schema Regression Tests',
      'group' => 'Schema',
    );
  }
  function setUp() {
    parent::setUp('schema', 'schema_test');
  }

  /**
   * Test API for adding tables
   */
  function testInspectionConflict518210() {

    // Drop the test table and re-create it with different columns.
    $table = 'schema_test_1';
    db_drop_table($table);
    $schema = array(
      'fields' => array(
        'sourceid' => array(
          'type' => 'int',
          'not null' => TRUE,
        ),
        'destid' => array(
          'type' => 'int',
          'not null' => TRUE,
        ),
      ),
    );
    db_create_table($table, $schema);

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

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

    // Inspect the table by using schema_compare().
    $schema = schema_get_schema();
    $comparison = schema_compare_table($schema['schema_test_1']);
    $this
      ->assertEqual($comparison['status'], 'different', 'Table does not match its schema.');
  }

}

Classes

Namesort descending Description
SchemaRegressionTest @file Regression tests for the Schema module