Skip to content
Snippets Groups Projects
Select Git revision
  • 779a70a0d473391461e5a9c3670c064fc6144ee7
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

database_test.test

Blame
  • Dries Buytaert's avatar
    - Patch #344575 by cdale: made the ANSI compatibility mode less strict to work...
    Dries Buytaert authored
    - Patch #344575 by cdale: made the ANSI compatibility mode less strict to work around a MySQL 5 bug.
    779a70a0
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    database_test.test 70.47 KiB
    <?php
    // $Id$
    
    /**
     * Dummy class for fetching into a class.
     *
     * PDO supports using a new instance of an arbitrary class for records
     * rather than just a stdClass or array. This class is for testing that
     * functionality. (See testQueryFetchClass() below)
     */
    class FakeRecord { }
    
    /**
     * Base test class for databases.
     *
     * Because all database tests share the same test data, we can centralize that
     * here.
     */
    class DatabaseTestCase extends DrupalWebTestCase {
    
      function setUp() {
        parent::setUp('database_test');
    
        $schema['test'] = drupal_get_schema('test');
        $schema['test_people'] = drupal_get_schema('test_people');
        $schema['test_one_blob'] = drupal_get_schema('test_one_blob');
        $schema['test_two_blobs'] = drupal_get_schema('test_two_blobs');
        $schema['test_task'] = drupal_get_schema('test_task');
    
        // This ends up being a test for table drop and create, too, which is nice.
        $ret = array();
        foreach ($schema as $name => $data) {
          if (db_table_exists($name)) {
            db_drop_table($ret, $name);
          }
          db_create_table($ret, $name, $data);
        }
    
        foreach ($schema as $name => $data) {
          $this->assertTrue(db_table_exists($name), t('Table @name created successfully.', array('@name' => $name)));
        }
    
        $this->addSampleData();
      }
    
      /**
       * Setup our sample data.
       *
       * These are added using db_query(), since we're not trying to test the
       * INSERT operations here, just populate.
       */
      function addSampleData() {
        // We need the IDs, so we can't use a multi-insert here.
        $john = db_insert('test')
          ->fields(array(
            'name' => 'John',
            'age' => 25,
            'job' => 'Singer',
          ))
          ->execute();
    
        $george = db_insert('test')
          ->fields(array(
            'name' => 'George',
            'age' => 27,
            'job' => 'Singer',
          ))
          ->execute();
    
        $ringo = db_insert('test')