[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/schema/tests/ -> schema_regression.test (source)

   1  <?php
   2  // $Id: schema_regression.test,v 1.1.2.1 2009/08/03 21:04:01 mikeryan Exp $
   3  /**
   4   * @file
   5   * Regression tests for the Schema module
   6   *
   7   */
   8  
   9  class SchemaRegressionTest extends DrupalWebTestCase {
  10    function getInfo() {
  11      return array(
  12        'name' => t('Schema Regression Tests'),
  13        'description' => t('Schema Regression Tests'),
  14        'group' => t('Schema'),
  15      );
  16    }
  17  
  18    function setUp() {
  19      parent::setUp('schema');
  20    }
  21  
  22    function tearDown() {
  23      $ret = array();
  24      db_drop_table($ret, 'schema_testtbl');
  25      db_query("DROP TABLE schema_testtbl");
  26      parent::tearDown();
  27    }
  28  
  29    /**
  30     * Test API for adding tables
  31     */
  32    function testInspectionConflict518210() {
  33      // Create an unprefixed table...
  34      $tablename = "schema_testtbl";
  35      $sql = "CREATE TABLE $tablename (
  36                fid INT NOT NULL,
  37                destid INT NOT NULL
  38              )";
  39      db_query($sql);
  40  
  41      // ...and a prefixed table, with a different column list
  42      $ret = array();
  43      $schema = array(
  44        'fields' => array(
  45          'sourceid' => array(
  46            'type' => 'int',
  47            'not null' => TRUE,
  48          ),
  49          'destid' => array(
  50            'type' => 'int',
  51            'not null' => TRUE,
  52          ),
  53        ),
  54      );
  55      db_create_table($ret, $tablename, $schema);
  56  
  57      // Do the full inspection, and get our specified tablename
  58      $inspect = schema_invoke('inspect');
  59      $fields = $inspect[$tablename]['fields'];
  60  
  61      // We should see only the columns from the prefixed version
  62      $this->assertFalse(isset($fields['fid']), t('fid does not exist'));
  63      $this->assertTrue(isset($fields['sourceid']), t('sourceid exists'));
  64      $this->assertTrue(isset($fields['destid']), t('destid exists'));
  65  
  66      // Inspect the table by using schema_compare().
  67      $comparison = schema_compare_table($inspect[$tablename]);
  68      $this->assertEqual($comparison['status'], 'same');
  69    }
  70  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7